Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Github 如果bitbucket中的master和branch都已更改,则合并时会发生什么情况_Github_Bitbucket_Git Branch_Git Merge_Git Merge Conflict - Fatal编程技术网

Github 如果bitbucket中的master和branch都已更改,则合并时会发生什么情况

Github 如果bitbucket中的master和branch都已更改,则合并时会发生什么情况,github,bitbucket,git-branch,git-merge,git-merge-conflict,Github,Bitbucket,Git Branch,Git Merge,Git Merge Conflict,我在本地机器上有一个来自master的分支。我知道如何合并一些东西来掌握回购。但问题是这个 假设其他开发人员通过将更改推送到主存储库来更改主存储库,同时我将按分支将更改合并到主存储库 在这种情况下会发生什么 在这种情况下我该怎么办。我试着从我的分支机构做以下事情 使用->git add* 然后使用->git提交-m“我的提交” 然后使用->git push-u origin my\u branch\u name推送到我的分支机构 然后使用->git checkout master将存储库更改为

我在本地机器上有一个来自master的分支。我知道如何
合并
一些东西来掌握回购。但问题是这个

假设其他开发人员通过将更改推送到主存储库来更改主存储库,同时我将按分支将更改合并到主存储库

在这种情况下会发生什么

在这种情况下我该怎么办。我试着从我的分支机构做以下事情

  • 使用->
    git add*
  • 然后使用->
    git提交-m“我的提交”
  • 然后使用->
    git push-u origin my\u branch\u name推送到我的分支机构
  • 然后使用->
    git checkout master将存储库更改为master
  • 然后使用->
    git merge my_branch_name将分支合并到master
到目前为止,它是成功的。然后我尝试使用以下命令推送(几分钟前,另一个开发人员推送到master)

  • git推送原始主机
然后它说如下

! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@bitbucket.org:abcdef/cups.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
在这个阶段,我应该怎么做

  • 我是否应该在合并步骤后得到一个
    ,然后再推(在这个阶段,如果我得到拉,会发生什么情况。)或者
  • 我需要做一些类似于
    git stash
    ,然后
    推送
    之类的事情吗

  • 希望你能帮上忙。非常感谢您的支持。

    您需要检索其他人推送的工作,并将其集成到本地,然后才能推送。 您可以直接执行“git pull”,或者更好地执行“git fetch”,然后执行“git merge”或“git rebase”。 fetch的优点是允许您查看其他用户推送了什么commit。然后,您可以决定进行合并或重新设置基础。rebase的优点是生成“更干净”的树


    如果您有一些正在进行的工作(已暂存的文件),您需要决定是否要在下一次推送中集成这些工作。然后,您需要决定放弃、隐藏它们或将它们集成到下一次提交中。

    您需要拉动
    远程/master
    (以获取所有远程更改),然后才能推动本地更改

  • 比方说,当您拉入
    remote/master
    时,有两个提交(A,B)

  • 然后,另一个开发人员将提交
    p
    推送到master

    remote/master: A -> B -> P
    local/master:  A -> B
    
  • 然后您在分支中提交了
    X
    (比如,
    功能

  • 现在将您的
    功能
    本地/主功能

    remote/master: A -> B -> P
    local/master:  A -> B -> X
    local/feature: A -> B -> X
    
  • 现在,您必须将
    remote/master
    拉入本地/master以获取remote/master的所有提交

    remote/master: A -> B -> P
    local/master:  A -> B -> P -> X    # now local/master has P (sync with remote/master)
    local/feature: A -> B -> X  
    
  • 将本地/主机推到远程

    remote/master: A -> B -> P -> X
    local/master:  A -> B -> P -> X
    local/feature: A -> B -> X
    
  • remote/master: A -> B -> P
    local/master:  A -> B -> P -> X    # now local/master has P (sync with remote/master)
    local/feature: A -> B -> X  
    
    remote/master: A -> B -> P -> X
    local/master:  A -> B -> P -> X
    local/feature: A -> B -> X