Skip to content

Instantly share code, notes, and snippets.

@kristenburgess25
Last active October 31, 2016 15:45
Show Gist options
  • Save kristenburgess25/3fc4995fd64f5a0d121493b9819bee1c to your computer and use it in GitHub Desktop.
Save kristenburgess25/3fc4995fd64f5a0d121493b9819bee1c to your computer and use it in GitHub Desktop.
###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
Run git stash save (or plain git stash , same thing). Check out the other branch and use git stash apply . ... You can in fact git stash save again, as git stash makes a "stack" of changes. If you do that you have two stashes, one just called stash —but you can also write stash@{0} —and one spelled stash@{1}
###git shortlog
Summarizes git log output in a format suitable for inclusion in release announcements. Each commit will be grouped by author and title.
If no revisions are passed on the command line and either standard input is not a terminal or there is no current branch, git shortlog will output a summary of the log read from standard input, without reference to the current repository.
### git commit --amend
Can be used to locally change the most recent commit message, but only before it has been pushed up to GitHub.
### git reset --hard
Returns a specified branch - often master - back to a specified previous commit. Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded.
### git reset --soft
Does not touch the index file or the working tree at all (but resets the head to <commit>, 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
Unclear...
### Find three different ways to display the git log. One example is git log --oneline.
* git log --follow - Continue listing the history of a file beyond renames (works only for a single file).
* git log --source - Print out the ref name given on the command line by which each commit was reached.
* --full-diff - Without this flag, git log -p <path>... shows commits that touch the specified paths, and diffs about the same specified paths. With this, the full diff is shown for commits that touch the specified paths; this means that "<path>…​" limits only commits, and doesn’t limit diff for those commits. (Note that this affects all diff-based output types, e.g. those produced by --stat, etc.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment