Git 拉取请求冲突

Git pull request conflict

我是 git 的新手,我担心我的代码会破坏主项目。

1 - 我从主项目中分叉了一个新的回购到我的帐户中。 我在上周更改了一些代码并向 master 提交了 pull request。

2 - 本周,我又做了同样的事情。我更改了一些代码并向主项目请求了请求,但它与主项目有冲突。

主项目的所有者说 "someone has changed in the master project and you need to accept it"。 但是我不知道怎么接受。

我试过这些命令

git pull // This returns Already up-to-date.
git checkout master // This returns Already on 'master'.
git merge origin/master // This returns Already up-to-date.
git status // This returns nothing to commit, working tree clean.

See the working tree example

首先检查接受主代码的冲突,然后在git repo

的根目录中执行

$git add . //Add all your changes to the git tree

$git status //checking what you are adding to the git

$git commit -m "fix conflicts" //add the submit comment to your submit action

$git rebase //compare the codes on the master with your local master when conflicts happened, rebase will accept your lastest changes and automatically overwrite the old codes then submit to the git head.

我强烈建议你使用 rebase 而不是 merge,因为 rebase 比 merge 更聪明,当发生冲突时,rebase 最重要的是将你的 git 树合并到origin master 树合并为一个,所以你可以用一个干净的 git 树继续开发。

据我了解,您似乎想将更改从主存储库拉入您的存储库(反之亦然)。

无论哪种方式,在 GitHub 中,您都可以创建拉取请求以将更改从 head fork 拉入您的个人克隆,或者您可以配置上游远程以从本地副本中获取更改。在那里,您将合并来自主存储库的更改,并将这些更改推回您在 GitHub.

上的分支

另请参阅 https://help.github.com/articles/syncing-a-fork/ 作为参考。

如果您只需要接受拉取请求,只需浏览到主存储库(假设您是具有写入权限的人)并检查待处理的拉取请求。