How to modify a specified commit?

后端 未结 16 1172
清酒与你
清酒与你 2020-11-22 01:53

I usually submit a list of commits for review. If I have the following commits:

  1. HEAD
  2. Commit3
  3. Commit2
16条回答
  •  [愿得一人]
    2020-11-22 02:42

    To get a non-interactive command, put a script with this content in your PATH:

    #!/bin/sh
    #
    # git-fixup
    # Use staged changes to modify a specified commit
    set -e
    cmt=$(git rev-parse $1)
    git commit --fixup="$cmt"
    GIT_EDITOR=true git rebase -i --autosquash "$cmt~1"
    

    Use it by staging your changes (with git add) and then run git fixup . Of course, it will still be interactive if you get conflicts.

提交回复
热议问题