什么时候“git pull --rebase”让我陷入困境? [英] When will `git pull --rebase` get me in to trouble?

查看:149
本文介绍了什么时候“git pull --rebase”让我陷入困境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道当我使用 git pull --rebase 时,git会重写历史记录,并在分支I中的所有提交之后移动我的本地提交刚从中拔出。



我不明白的是,这将是一件坏事。人们谈论如何解决 git pull --rebase 问题,你最终可能会遇到一个其他人无法提供的分支。但是我不明白这是如何实现的,因为你所做的只是在你所从的分支之上重播你本地的,尚未公开的提交。那么,那里有什么问题?如果你只发布(推送)了一些提交,这只是一个问题,因为他们很难合并到已经有这些提交的其他回购。因为他们的SHA1已经改变了,所以Git会试着在这些回购站上重新播放它们。

如果你还没有(再次推送任何提交),任何rebase都应该是安全的。



所以这里的问题是:你肯定所有本地提交你实际上仍然是...本地?

你确定' git pull --rebase '之后' git pull - rebase '?



如果您正在使用'私人分支'(一个您从未推送过的分支,但仅合并或重新绑定公共分支,你会推动的分支),那么你可以安全地在任何时候重新分配这个私人分支。



最后,这一切都取决于合并工作流程您已选择建立

I understand that when I use git pull --rebase, git will re-write history and move my local commits to occur after all of the commits in the branch I just pulled from.

What I don't understand is how this would ever be a bad thing. People talk about getting in to trouble with git pull --rebase where you can end up with a branch that other people can't pull from. But I don't get how that's possible since all you're doing is replaying your local, not-yet-public, commits on top of the branch you pulled from. So, what's the problem there?

解决方案

It is only an issue if you have only published (pushed) some of your commits, because they would be harder to merge to other repos which have already those commits. Since their SHA1 have changed, Git would try to replay them again on those repos.

If you have not (pushed any of those commits again), any rebase should be safe.

So the issue here is: are you sure that all the local commit you are rebasing are still actually... local?
And are you sure of that 'git pull --rebase' after 'git pull --rebase'?

If you are working on a 'private branch' (a branch that you never pushed, but only merge or rebase on a public branch, one that you will push), then you are safe to rebase that private branch any time you want.

In the end, it all depends on the workflow of merge you have chosen to establish.

这篇关于什么时候“git pull --rebase”让我陷入困境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆