Git Commands – 1

Revert to a Commit

This Command can be used to revert your git repository to a specific commit id even after merge commit is pushed to remote.

$ git reset --merge 4a5645b
$ git push origin [branch] -f 

Without -f, it will not allow you to push the reverted branch since the remote is ahead of your version

Cherry-pick a commit

When the commit stack is grown but you still need to merge the changes from certain commit, Cherry-pick command will do the trick

For example, let’s say you need to merge circled commit to releaseUAT branch but not the later commits.

(i) Checkout and get the latest content from releaseUAT branch

$ git checkout releaseUAT<br>git pull

(ii) Cherry-pick the changes from circled commit

$ git cherry-pick 4a5645b

(iii) Push releaseUAT branch to remote.

$ git push origin releaseUAT