git 我可以重新设置旧提交吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4963261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
can i rebase old commits?
提问by griotspeak
I have just started using git. Rebase is great stuff. I should have used it in a specific earlier case.
我刚刚开始使用 git。Rebase 是个好东西。我应该在一个特定的早期案例中使用它。
is there a perfectly acceptable way to rebase old commits for the sake of clear commits?
为了清晰的提交,是否有一种完全可以接受的方式来重新设置旧提交?
回答by Brian L
You should positively only do this for commits that have not been pushed upstream. That said, I find it easiest to use git rebase -i <commit>
where <commit>
is the id of a commit that is at least as old as the newest one you do not want to mess with. When your editor pops up, it will contain instructions about how to squash and/or delete commits.
您应该积极地只对尚未推送到上游的提交执行此操作。这么说,我觉得它最容易使用的git rebase -i <commit>
地方<commit>
是id的承诺是至少一样老,你不想惹最新的一个。当您的编辑器弹出时,它将包含有关如何压缩和/或删除提交的说明。
回答by Amber
In general, if you've shared a commit with someone else, don't rebase it.
通常,如果您与其他人共享了一个提交,请不要对其进行变基。
If you haven't shared a commit with anyone else, you can do whatever you want to it.
如果您尚未与其他人共享提交,则可以对其进行任何操作。
See the "RECOVERING FROM UPSTREAM REBASE" section of the git-rebase
manpagefor more info.
有关详细信息,请参阅git-rebase
联机帮助页的“从上游 REBASE 恢复”部分。