Git另一个遥控器的合并分支

时间:2012-10-16 18:28:28

标签: linux git command-line

如今,我看到很多来自Linux Torvalds和/或Gitster的提交看起来像这样:

Merge branch 'maint' of git://github.com/git-l10n/git-po into maint …
* 'maint' of git://github.com/git-l10n/git-po:
  l10n: de.po: fix a few minor typos

或:

Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upst… …
…ream-linus

Pull MIPS update from Ralf Baechle:
...
* 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: (22 commits)
  MIPS: SNI: Switch RM400 serial to SCCNXP driver
...

我不知道怎么会这样做,虽然,我知道 git remote git checkout git merge 用于合并分叉(或“拉取请求”),但它不会生成此类消息,为什么?如何做到这一点(请提供例子)?

P.S:我是Linus Torvalds提交的粉丝等,就像他的合并描述的详细程度一样; P

P.S:这就是我过去合并的方式:

git remote add anotherremoot
git checkout -b anotherbranch
git pull remoteshortcut
...do tests...
git checkout master
git merge anotherbranch
git push

以上我从以下例子中学到:http://viget.com/extend/i-have-a-pull-request-on-github-now-what

1 个答案:

答案 0 :(得分:35)

只需使用git pull将远程分支拉入master

git remote add something git://host.example.com/path/to/repo.git
git checkout master
git pull something master

或者在不添加遥控器的情况下执行此操作:

git pull git://host.example.com/path/to/repo.git

git pull获取远程分支,并将其合并到本地分支中。如果可能,它会执行快进合并,这意味着它会将当前主服务器更新为最新提交,而不会生成合并提交。但如果双方都有变化,它会进行合并,就像你看到Linus和Junio所做的那样,包括远程URL。

如果您想保证合并提交,即使它可以快进,也可以git pull -no-ff。如果您想确保pull永远不会创建合并提交(如果双方都有更改,则会失败),请执行git pull --ff-only

如果要包含更详细的消息,例如Linus提供的完整日志,请执行git pull --log。如果要编辑邮件,请使用git pull --edit,而不是仅使用自动创建的邮件。有关更多选项,请参阅documentation for git pull

相关问题