[英]Rewriting git commit history
Assuming we have a git commit history which looks like: 假设我们有一个git提交历史,如下所示:
ZZ [origin/master] A -> B -> C -> D -> E [master]
ZZ [origin / master] A - > B - > C - > D - > E [master]
We want to: 我们想:
A
. A
之前。 E
. E
的工作目录。 A..E
in to a single commit. A..E
所有变更集捆绑到单个提交中。 The result should look like: 结果应如下所示:
ZZ -> XX [master][origin/master]
ZZ - > XX [master] [origin / master]
Where XX is the commit encompassing the changes of prior commits A..E 其中XX是包含先前提交A..E的更改的提交
You can try: 你可以试试:
git reset --hard E
git reset --soft ZZ
git commit 'comment'
git push orgin master
--soft
- 柔软的
Does not touch the index file nor the working tree at all (but resets the head to , just likeall modes do).
根本不触摸索引文件和工作树(但是将头重置为,就像所有模式一样)。 This leaves all your changed files "Changes to be committed", as git status would putit.
这将保留所有已更改的文件“要提交的更改”,因为git status将为putit。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.