How do I keep the commit message when editing commits via git rebase --interactive?

前端 未结 4 2147
北海茫月
北海茫月 2021-02-05 13:11

I\'m currently in the midst of a git rebase --interactive session, where I\'m editing a commit. I\'m proceeding as suggested by How can I split up a Git commit bur

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-05 13:30

    I adapted some examples in git-commit(1) and git-reset(1):

    $ git reset HEAD^
    $ git add ...                 # stage the first part of your split
    $ git commit -m 'part one'
    $ git commit -a -c ORIG_HEAD  # start with the earlier commit message
    

    If you're worried about doing something that might change ORIG_HEAD, you could instead do:

    $ SAVED=$(git rev-parse HEAD)
    $ git reset HEAD^
    ...
    $ git commit -a -c $SAVED   # start with the earlier commit message
    

提交回复
热议问题