git pull --rebase
开始情况(没有未推送的更改,>
表示当前分支):
o C [> master][origin/master]
|
o B
|
o A
|
...
在 git fetch
之后,日志结构通常看起来像
o E [origin/master]
|
o C'
|
o B'
|
o D
|
| o C [>master]
| |
| o B
|/
o A
|
...
现在 git rebase origin/master master< /code> 经常会产生冲突。
git pull --rebase
是否更聪明,只需使用 git reset
使 master
也指向 E
如果 master
==origin/master
最初?
Start situation (no unpushed changes, >
indicates the current branch):
o C [> master][origin/master]
|
o B
|
o A
|
...
After a git fetch
the log structure often looks like
o E [origin/master]
|
o C'
|
o B'
|
o D
|
| o C [>master]
| |
| o B
|/
o A
|
...
Now git rebase origin/master master
often produces conflicts. Is git pull --rebase
smarter and just uses git reset
to make master
also point to E
if master
==origin/master
initially?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
git pull --rebase 与 git fetch 不同。 git 变基。不幸的是,
git-pull
手册页对这种差异相当神秘:事实证明,这种差异并不涉及
git reset
正如原始海报猜测的那样 - 事实上它涉及reflog(请参阅此处如果您以前没有遇到过该术语)。有关 git pull --rebase 中额外魔力的完整故事,请参阅此答案:
https:// stackoverflow.com/a/11531502/179332
git pull --rebase
is NOT the same asgit fetch; git rebase
. Unfortunately thegit-pull
man page is rather cryptic about the difference:It turns out that the difference doesn't involve
git reset
as the original poster guessed - in fact it involves the reflog (see here if you haven't encountered that term before).For the complete story around the extra magic in
git pull --rebase
, see this answer:https://stackoverflow.com/a/11531502/179332
git pull --rebase
类似于以下内容:因此,在您的情况下,它将像这样离开存储库:
请注意,您拥有的两个提交与
origin
不同> 在提交 E 之上重新创建。git pull --rebase
is similar to what the following would do:So in your case it will leave the repository like this:
Note that the two commits you have are different from
origin
where re-created on top of commit E.您可以使用 rebase 而不是合并来拉取 - 这就是我的团队的工作方式,而且效果很好。
来自“一些你不知道的 git 技巧”:
You can pull with rebase instead of merge - that's the way my team works and it works quite well.
From "A few git tips you didn't know about":