How to modify a specified commit?

后端 未结 16 1185
清酒与你
清酒与你 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:51

    If you haven't already pushed the commits then you can go back to a previous commit using git reset HEAD^[1,2,3,4...]

    For example

    git commit  -m "Updated files 1 and 2"
    git commit  -m "Updated file 3"
    

    Oops, forgot to add file2 to the first commit...

    git reset HEAD^1 // because I only need to go back 1 commit
    
    git add 
    

    This will add file2 to the first commit.

提交回复
热议问题