How to re-commit a past commit if someone overwrote my commit

You can do that typing the following commands:

$ git reflog

then select the ID of the commit that you want to retrieve.

Then type the following command:

$ git cherry-pick <'ID'>

Instead of <'ID'> enter the ID from the above reflog.

Then you will have the changes of that commit.

Now check if anything is still remaining by:

$ git status

If anything is in unstaged commit, then add it by the following commands and commit:

$ git add -A //Any other option or the name of the file with the path that you want to commit
$ git commit -m "Your message here for that commit"
$ git push

I hope this answer is what you are expecting for.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)