在不使用 Rebase 的情况下重做 GIT 中的提交历史记录
自从问我的上一个问题结果是关于使用 GIT 进行 rebase 以来,我决定根本不想进行 rebase 。相反,我想要:
- 分支
- 工作 工作工作,随时签入和推送
- 扔掉所有这些提交并假装它们从未发生过(因此在工作结束时进行一次干净的提交)
我目前通过将文件复制到新的文件来执行此操作目录,然后将它们复制回一个新分支(与我的工作分支在同一点分支),然后将其合并到 master 或任何地方。
这真的很糟糕吗?为什么?更重要的是:是否有更好的/GIT 方法来做到这一点? git rebase -i
迫使我合并(并选择和挤压)。
Since asking my last question which turned out to be about rebasing with GIT, I have decided that I don't want to rebase at all. Instead I want to:
- Branch
- Work work work, checking in and pushing at all times
- Throw out all of those commits and pretend they never happened (so one clean commit at the end of work)
I do this currently by copying the files to a new directory and then copying them back in to a new branch (branched at the same point as my working branch), and then merging that into master
or wherever.
Is this just plain bad and why? More important: Is there a better/GIT way to do this? git rebase -i
forces me to merge (and pick, and squash).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法是软重置。
所以检查你的主题分支:
工作,工作,工作。
对此感到满意,您可以在 master 之上进行新的单个提交,
现在合并到 master (这将是快进)并整理主题分支。 (请注意,如果您准备记住或标记 master 所在位置并且只在 master 上工作而无需分支,则不需要执行此操作,您可以只执行
git reset --soft old-master
和 git commit ,您就不需要这些最后的清理步骤。)The easiest thing to do is a soft reset.
So checkout your topic branch:
work, work, work.
Happy with this, you can make a new single commit on top of master
Now merge to master (it will be a fast-forward) and tidy up the topic branch. (Note that you don't need to do this if you are prepared to remember or tag where master was and just work on master without branching, you could have just done
git reset --soft old-master
andgit commit
and you wouldn't need these last clean-up steps.)您还可以使用
git merge
与--squash
选项。You can also use
git merge
with the--squash
option.