Custom Search

Thursday, January 23, 2014

Git How to modify a specified commit

You can use git rebase, for if you want to modify back to commit hu783vgt45.

1)
$ git rebase --interactive hu783vgt45^
In the default editor, modify 'pick' to 'edit' in the line whose commit you want to modify.
Here 'edit' will apply the diff of commit you selected and store all the commits which came after that in a temporary location.

2)
Make your changes to the commit hu783vgt45 you selected and then stage (prepare for commit) them with
$ git add


3)Commit the changes of hu783vgt45 (here you can change commit message)
$ git commit --amend

4)
To return back to the previous head commit (original last commit).
Restore all commits which stored in the temporary location during rebase.
$ git rebase --continue

No comments:

Post a Comment