Vault7: CIA Hacking Tools Revealed
Navigation: » Latest version
Owner: User #524297
Git Tips & Tricks
Add your best Git tricks here!
Share the love! |
---|
The "I forgot something in my last commit" Trick
# first: stage the changes you want incorporated in the previous commit
# use -C to reuse the previous commit message in the HEAD
$ git commit --amend -C HEAD
# or use -m to make a new message
$ git commit --amend -m 'add some stuff and the other stuff i forgot before'
The "Oh crap I didn't mean to commit yet" Trick
# undo last commit and bring changes back into staging (i.e. reset to the commit one before HEAD)
$ git reset --soft HEAD^
The "That commit sucked! Start over!" Trick
# undo last commit and destroy those awful changes you made (i.e. reset to the commit one before HEAD)
$ git reset --hard HEAD^
The "Oh no I should have been working in a branch" Trick
# takes staged changes and 'stashes' them for later, and reverts to HEAD.
$ git stash
# creates new branch and switches to it, then takes the stashed changes and stages them in the new branch. fancy!
$ git stash branch new-branch-name