Git 怎么用 rebase 合并几个 commit
世界只因有你
世界只因有你 2017-05-02 09:22:52
0
1
535

据说 Git 可以通过 rebase 合并几次提交,最终在历史记录中只留下合并后的那一个。

因为我在改一个 bug 的时候中途提交了几次,但最后需要把中间几次提交都取消掉,直接合并最后一次提交上去,比如

aaaaaa 修改前小小的重构 bbbbbb 修改拼写错误 cccccc 重算 a 过程 dddddd 重算 b 过程 eeeeee fix #2382

我想最终在历史记录只有

abcdef fix #2382,重算了 a、b 过程

应该怎么做?
我平时用 SmartGit,不过用命令行解决也行

世界只因有你
世界只因有你

reply all (1)
伊谢尔伦

git rebase -i
Set the front of unnecessary commits to s, save and exit, and then edit the new log, which is more complicated

There is another method, but it requires aaaaa to be the latest commit
git reset --soft 然后重新git commit

Anyway, these two methods are relatively dangerous operations. It is recommended that novices find a favorite project to try first

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!