Posted By

narkisr on 02/01/10


Tagged

git revert commit ammend


Versions (?)

Reverting commit changes from HEAD


 / Published in: Bash
 

URL: http://cheat.errtheblog.com/s/git/

We can fix commits that we made by using --amend option.

  1. # we have a change
  2. ronen@Lunar:~/dummy$ gits
  3. # On branch master
  4. # Changed but not updated:
  5. # (use "git add <file>..." to update what will be committed)
  6. # (use "git checkout -- <file>..." to discard changes in working directory)
  7. #
  8. # modified: bla
  9. #
  10. no changes added to commit (use "git add" and/or "git commit -a")
  11. ronen@Lunar:~/dummy$ gitc 'added a wrong change'
  12. [master 14af00a] added a wrong change
  13. 1 files changed, 1 insertions(+), 0 deletions(-)
  14. ronen@Lunar:~/dummy$ gits
  15. # On branch master
  16. nothing to commit (working directory clean)
  17.  
  18. # weve made a bad commit
  19. ronen@Lunar:~/dummy$ cat bla
  20. initial value
  21. wrong change to make
  22. # lets fix that (we replace it with an empty line
  23. ronen@Lunar:~/dummy$ vi bla
  24. ronen@Lunar:~/dummy$ cat bla
  25. initial value
  26. <-- this is an empty line!
  27. ronen@Lunar:~/dummy git commit --amend bla

Report this snippet  

You need to login to post a comment.