Skip to content

Instantly share code, notes, and snippets.

@s-espinosa
Last active April 14, 2016 15:55
Show Gist options
  • Save s-espinosa/66798d74aa2c457a62546824acb23607 to your computer and use it in GitHub Desktop.
Save s-espinosa/66798d74aa2c457a62546824acb23607 to your computer and use it in GitHub Desktop.
  • git stash: records the current state of the working directory and index, but returns you to a clean working directory.
  • git stash apply: applies the changes of a previously stashed state to the current working version. Leaves the stashed version in the stashed list. Can fail with conflicts.
  • git shortlog: summarizes git log output grouped by author and title.
  • git commit --amend: amend the last locally created commit that has not been pushed. In order to amend commits that have already been pushed, use --amend and then push with force. In order to modify older commits, use rebase.
  • git reset --hard: resets the staging area to match the most recent commit and obliterates changes made since then. If a previous commit is specified, reverts to that commit and obliterates all commits after.
  • git reset --soft: like reset --hard, but leaves the changes in place and uncommited.
  • git reset --hard HEAD~2: specifies the number of commits back that you want to remove.

Find three different ways to display the git log. One example is git log --oneline.

  • git log --oneline --all --graph --decorate --simplify-by-decoration"
  • git log --pretty=format:"%Cgreen%h$Creset %Cblue%ad%Creset %s%C(yellow)%d%Creset %Cblue[%an]%Creset" --graph --date=short
  • git log --graph --abbrev-commit --decorate --date=relative --format=format:"%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bol d yellow)%d%C(reset)" --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment