Skip to content

Instantly share code, notes, and snippets.

@bethsecor
Last active January 7, 2016 21:05
Show Gist options
  • Save bethsecor/c68603f15ac733adcbb6 to your computer and use it in GitHub Desktop.
Save bethsecor/c68603f15ac733adcbb6 to your computer and use it in GitHub Desktop.

Descriptions of git commands:

  • git stash: Records the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.
  • git stash apply: Applies the stashed changes to the current branch you are working on. Does not remove the state from the stash list.
  • git shortlog: Summarizes git log output.
  • git commit --amend: convenient way to fix up the most recent commit. It lets you combine staged changes with the previous commit instead of committing it as an entirely new snapshot. It can also be used to simply edit the previous commit message without changing its snapshot.
  • git reset --hard: Resets the index and working tree (throws away uncommited changes). Any changes to tracked files in the working tree since are discarded.
  • git reset --soft: Does not touch the index file or the working tree at all (but resets the head to , just like all modes do). This leaves all your changed files "Changes to be committed", as git status would put it.
  • git reset --hard HEAD~2: command moves the current branch backward by two commits, effectively removing the two snapshots we just created from the project history.

References:

Three different ways to display the git log:

  • git log --oneline
  • git log --decorate
  • git log --graph --oneline --decorate
  • git shortlog
  • git log --pretty=format:"%cn committed %h on %cd" (%cn = commiter name, %h = abbreviated commit hash, %cd = committer date)

Reference: https://www.atlassian.com/git/tutorials/git-log/formatting-log-output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment