Remove old git commits

前端 未结 4 1886
后悔当初
后悔当初 2020-12-07 17:59

I\'m very new to git, and was wondering if something like this is possible?

>git log --pretty=oneline --abbrev-commit
2f05aba Added new feature
3371cec Fi         


        
4条回答
  •  遥遥无期
    2020-12-07 18:43

    This is possible with git rebase. Try the following

    git rebase -i HEAD~4
    

    and then, follow the interactive instructions in your editor. In the first step you "squash" the commits. It should look something like this:

    pick 2f05aba ... will be preserved
    squash 3371cec ... will be squashed with daed25c
    squash daed25c ... will be squashed with e2b2a84
    pick e2b2a84 .. will contain this and 3371cec and daed25c
    

    In the second step you can edit the commit messages.

提交回复
热议问题