Modifying commits that did not receive push

3

I need to edit the commit message and add another file.

I have not yet given Push in commit, is there a way to resolve this?

    
asked by anonymous 24.04.2018 / 13:41

1 answer

2

Yes!

You can undo your last local commit (without pushing), returning to the previous state of the commit and without losing any changes made to it.

Just do it:

git reset --soft HEAD~1

Being 1 the number of back commands you want to undo. Since you only want the latter, you will use 1 (one).

After this, your pre-commit changes will all be shown as unstaged in git status and you will need to add them again with git add . .

Now just add the file you want and commit again by changing its message.

    
24.04.2018 / 13:55