简体   繁体   English

另一个远程的 Git 合并分支

[英]Git merge branch of another remote

Nowadays, I see a lot of commits from Linus Torvalds and/or Gitster that look like so:现在,我看到很多来自 Linus 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

or:要么:

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
...

I have no idea how would one do that, although, I know about the git remote and git checkout and git merge that I use to merge forks (or "pull requests") but it does not generate such message, why?我不知道如何做到这一点,虽然,我知道用于合并分叉(或“拉取请求”)的git remotegit checkoutgit merge ,但它不会生成这样的消息,为什么? and how would someone do that (provide examples please)?有人会怎么做(请提供示例)?

PS: I'm a fan of Linus Torvalds commits etc, like how detailed the description of his merges look ;P PS:我是 Linus Torvalds 提交等的粉丝,比如他的合并描述的详细程度;P

PS: This is how I used to merge stuff: PS:这就是我用来合并东西的方式:

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

The above example I learned from: http://viget.com/extend/i-have-a-pull-request-on-github-now-what上面的例子我从: http : //viget.com/extend/i-have-a-pull-request-on-github-now-what

Just use git pull to pull the remote branch into master :只需使用git pull将远程分支拉入master

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

Or do it without adding a remote:或者在不添加遥控器的情况下进行:

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

git pull fetches the remote branch, and merges it into the local branch. git pull获取远程分支,并将其合并到本地分支。 If possible, it does a fast-forward merge, which just means that it updates the current master to the latest commit without generating a merge commit.如果可能,它会进行快进合并,这仅意味着它将当前 master 更新到最新提交,而不会生成合并提交。 But if there are changes on both sides, it will do a merge, like the ones you see Linus and Junio doing, with the remote URL included.但是如果双方都有变化,它会进行合并,就像你看到 Linus 和 Junio 所做的那样,包括远程 URL。

If you want to guarantee that you get a merge commit, even if it could fast forward, do git pull -no-ff .如果你想保证你得到一个合并提交,即使它可以快进,做git pull -no-ff If you want to make sure that pull never creates a merge commit (so fails if there are changes on both sides), do git pull --ff-only .如果您想确保pull永远不会创建合并提交(如果双方都有更改,则会失败),请执行git pull --ff-only

If you want to include a more detailed message, like the full log that Linus provides, do git pull --log .如果您想包含更详细的消息,例如 Linus 提供的完整日志,请执行git pull --log If you want to edit the message, instead of just using the automatically created message, use git pull --edit .如果要编辑消息,而不是仅使用自动创建的消息,请使用git pull --edit See documentation for git pull for more options.有关更多选项,请参阅git pull文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM