Git commands & what they do
-
git stash
- Stashes away dirty working directory in order to return to a clean working directory, when there is the desire to record the current state of the working directory and the index before going back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.
- 'save' is default --> so, really
git stash save
if want to be explicit - Resource: https://git-scm.com/docs/git-stash
-
git stash apply
- Restores modifications that were stored away
- Beware that it may potentially be restored on top of a different commit
-
git shortlog
- Summarizes
git log
output in a format whereby each commit is grouped by author and title - Resource: https://git-scm.com/docs/git-shortlog
- Summarizes
-
git commit --amend
- Replaces the tip of the current branch by creating a new commit. The message from the original commit is used as the starting point when no other message is specified in the command line via flag options
-m
,-F
,-c
. git commit --amend --no-edit
amends a commit without changing its commit message- https://git-scm.com/docs/git-commit
- Replaces the tip of the current branch by creating a new commit. The message from the original commit is used as the starting point when no other message is specified in the command line via flag options
-
git reset --hard
- Resets the index and working tree. Any changes to tracked files in the working tree since are discarded.
- https://git-scm.com/docs/git-reset
-
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
- (?) Rewind the master branch to get rid of those two commits.
-
Three different ways to display the git log:
- git log --oneline
- git log --oneline --decorate
- git log --graph --oneline --decorate
- Resource: https://www.atlassian.com/git/tutorials/git-log/formatting-log-output
Useful GithHub keyboard shortcuts: