[英]How can I use git reset for editing old commits
1) Is there a way to edit or squash commits without using the Interactive mode of git rebase? 1) 有没有办法在不使用 git rebase 的交互模式的情况下编辑或压缩提交? 2) How do git reset --keep
and git reset --merge
work and how do they differ? 2) git reset --keep
和git reset --merge
如何工作,它们有何不同? I have read the git book, but I do not understand it yet...我看过git这本书,但是我还没有看懂……
You can do你可以做
git reset --soft <commit>
git commit -m "squashed"
to squash all commits between your current HEAD
and <commit>
.压缩当前HEAD
和<commit>
之间的所有提交。
The git reset
part undos all commits that came after <commit>
but will keep the changes staged (you can check this with git status
). git reset
部分撤消了<commit>
之后的所有提交,但将保持更改暂存(您可以使用git status
进行检查)。 The subsequent git commit
will commit all those staged changes as a single commit.随后的git commit
会将所有这些分阶段的更改作为单个提交提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.