在 Bitucket 中创建拉取请求错误 [英] Creating a pull request error in Bitucket

查看:33
本文介绍了在 Bitucket 中创建拉取请求错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小团队在一个存储库上工作,我要求我的每个团队成员在那里创建自己的分支并在那里工作,他们都克隆了存储库,然后他们执行了以下命令:

I'm having a small team working on a single repository, I asked my each teammates to create there own branch and work on there branch, all of them cloned the repository and then they did the following command:

git checkout -b BitPankaj

BitPankaj 是插图分支名称,他们开始在这个分支上工作并通过

BitPankaj is illustration branch name, they started working on this branch and uploaded there work through

git branch --set-upstream origin BitPankaj

现在在我的存储库中,我可以看到这些分支出现并且它们的提交也可见:

Now in my repository I can see that those branch appears and their commits are also visible:

和分支:

现在他们每个人都试图创建一个拉取请求来审查那里的代码并合并到主分支.所以他们尝试做这样的事情:

Now each one of them where trying to create a pull request to review there code and merge to master branch. so they tried doing something like this:

但是它会抛出无关分支的错误:

But it throws an error of unrelated branches:

保存此拉取请求时发生以下错误:无关分支

The following error(s) occurred saving this pull request: Unrelated branches

我们正在学习使用 git,帮我解决这个问题.

We people are learning to work on git, help me out with this.

推荐答案

这是因为 BitPankaj 分支是孤儿分支.

This is because the BitPankaj branch is an orphan branch.

这意味着分支 BitPankaj 不是从 master 分支创建的(如您所料),但可以使用 git checkout --orphan BitPankaj 代替.分支结构如下:

That means the branch BitPankaj didn’t created from master branch (as you expected), but may use git checkout --orphan BitPankaj instead. The branch structure looks like:

A---B---…---C   master
D---…---E    BitPankaj

您可以仔细检查您的本地存储库.更新/拉取分支并将日志显示为图表:

You can double check in your local repo. Update/pull the branches and show logs as graph:

git checkout master
git pull origin master
git checkout BitPankaj
git pull BitPankaj
git log --oneline --decorate --graph --all 
#Or you can use gitk --all if you installed git bash

为了在 BitPankajmaster 之间创建拉取请求,你应该更改 BitPankaj 分支基于 master 分支.

In order to create pull request between BitPankaj and master, you should change BitPankaj branch based from master branch.

  • master分支的最新版本(提交C)更改BitPankaj:

  • To change BitPankaj based from the latest version (commit C) of master branch:

git rebase master BitPankaj
git push -f origin BitPankaj

然后提交历史会像:

A---B---…---C   master
             \
              D---…---E   BitPankaj

  • 要根据 master 分支的旧版本(例如 commit B)更改 BitPankaj 分支:

  • To changes BitPankaj branch based from an old version (such as commit B) of master branch:

    git rebase <commit id for B> BitPankaj
    git push -f origin BitPankaj
    

    然后提交历史会像:

    A---B---…---C   master
         \
          D---…---E   BitPankaj
    

  • 然后您可以创建拉取请求以成功将 BitPankaj 合并到 bitbucket 上的 master 分支.

    Then you can create pull request to merge BitPankaj into master branch on bitbucket successfully.

    这篇关于在 Bitucket 中创建拉取请求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆