Skip to content

Instantly share code, notes, and snippets.

@amatellanes
Last active May 4, 2021 22:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amatellanes/9328323 to your computer and use it in GitHub Desktop.
Save amatellanes/9328323 to your computer and use it in GitHub Desktop.
Handy Git commands
$ git reset --hard HEAD~1
$ git push -f # removes last commit.
$ git diff --staged # will show you the diff that you're about to commit.
$ git commit -am "First commit" # adds all changes to tracked files and uses the commit message from the command-line.
$ git diff -M # only considers a file that disappeared as the source of a rename.
$ git diff -b # the -b means ignore whitespace, useful since we've changed some html indenting.
$ git log -n 1 --format=%H # Gets the hash of the current commit that’s in your local tree.
$ git log --graph --oneline --decorate # Shows repo history.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment