【发布时间】:2015-05-20 18:26:45
【问题描述】:
这个问题可能听起来微不足道,但我真的不知道如何正确地做...我正在做一个开源项目,源代码在 Github 上,所以我已经分叉了那个 repo,添加了一个“远程上游”指向原始存储库,并且还在我的分叉存储库中创建了一个分支并进行了一些更改。它看起来像这样:
$git remote -v
origin https://github.com/my_github_account/project_name (fetch)
origin https://github.com/my_github_account/project_name (push)
upstream https://github.com/project_name/repo_name (fetch)
upstream https://github.com/project_name/repo_name (push)
$git branch
master
* test_branch
在对我的“test_branch”进行一些更改之后,上游也有一些新的更改,所以我想从上游获取最新的更改,将它们合并到我的 test_branch 中,看看是否一切正常。我试过了:
git pull upstream master
为此目的可以正常工作,但它也创建了一个“新提交”,因为当我向项目创建拉取请求时也会显示提交消息,如果我以这种方式频繁拉取上游更改,那么会很多
Merge branch 'master' of https://github.com/project_name/repo_name into test_branch
消息显示,这对其他人来说有点混乱,我也没有看到其他人的拉取请求包含此类消息......(或者也许有一些方法可以摆脱这些消息?)
我也google了一下,试过了:
git pull --rebase upstream master
然后做:
git push origin test_branch
但后来我收到一些错误,例如:
! [rejected] test_branch -> test_branch (non-fast-forward)
error: failed to push some refs to 'https://github.com/my_github_account/project_name'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
嗯...我不清楚这意味着什么...也许我的做法不对...那么从上游获取最新更改的程序通常是什么,整合/将它们合并到我的分支中?
提前致谢!
【问题讨论】: