Monday, February 17, 2014

How quickly revert last pushed commit

I found that operation of giving permission for awhile in gitolite force me  do commit-push and revert of changes in few minutes , here is how to do revert quickly for last pushed commit (it hash is on output):

02:45 PM ~/java/git/gitolite-admin/conf [master|● 1] $ git commit -m "fix for hotfix branch"
[master 9d8f0ae] fix for hotfix branch
 1 file changed, 1 insertion(+), 1 deletion(-)
02:45 PM ~/java/git/gitolite-admin/conf [master ↑·1|✔] $ git push
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 385 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
   040e849..9d8f0ae  master -> master
02:46 PM ~/java/git/gitolite-admin/conf [master|✔] $ git revert 9d8f0ae

You can test that hash-code is the same by review of logs before revert:
02:45 PM ~/java/git/gitolite-admin/conf [master|✔] $ git log
commit 9d8f0ae3a56152067341c4f2c301c4d232dcbda0

No comments:

Post a Comment