2016-11-29 90 views
0

我必须对回购请求进行拉取请求。 我克隆项目,它只有一个分支:masterGit - 解决拉请求之前的主分支和功能分支之间的冲突

我签出一个新的分支feature并提交我的更改到这个分支。

我把我的分支推到Github上,现在我可以提出拉取请求。所以我这样做,但它现在告诉我,我有冲突。 enter image description here

我明白这个问题。 masterfeature之前,因为我没有“拉”最后一次变更,当我对feature进行工作时,已经对主人进行了更改。

我该如何解决?我怎样才能将主人的最后变化“拉”到我的feature分支?

+1

您需要在本地合并或重新绑定并推送结果。 – CollinD

回答

4

通过合并固定:

git fetch origin   # gets latest changes made to master 
git checkout feature  # switch to your feature branch 
git merge master   # merge with master 
# resolve any merge conflicts here 
git push origin feature # push branch and update the pull request 

通过底垫固定:

git fetch origin   # gets latest changes made to master 
git checkout feature  # switch to your feature branch 
git rebase master  # rebase your branch on master 
# complete the rebase, fix merge conflicts, etc. 
git push --force origin feature 

仔细注意,作为底垫有效地重写大概需要重订后--force选项上推feature分支。这意味着您需要通过强制推送来覆盖GitHub中的旧分支。

无论您是进行合并还是重新绑定,之后都应该解决冲突,并且您的审阅者应该能够完成请求。

0
$ git checkout feature     
$ git fetch 
$ git pull origin master 

现在应该发生冲突。现在,如果你想保持主人的变化

$ git status       # See the untracked files (conflict files) 
$ git checkout --theirs <file-name> # Accept the master's change 

,或者,如果你想保持你的(features变化) $ git的结帐--ours

添加,提交和推feature分支

$ git commit -am <commit-message>  # Add & Commit 
$ git push origin HEAD     # Push to remote feature branch