Skip to content

Instantly share code, notes, and snippets.

@sujeet-agrahari
Created February 6, 2021 12:52
Show Gist options
  • Save sujeet-agrahari/55c083a10d2f850cf0d6402b754f5152 to your computer and use it in GitHub Desktop.
Save sujeet-agrahari/55c083a10d2f850cf0d6402b754f5152 to your computer and use it in GitHub Desktop.
git log = git history
git log --all --decorate --oneline --graph = commit history graph
git branch (branch-name) = create a branch
git checkout (branch-name) = checkout a branch/move head pointer
git commit -a -m "commit message" = commit all modified and tracked files in on command (bypass separate 'git add' command)
git diff master..SDN = diff between 2 branches
git merge (branch-name) = merge branches (fast-forward and 3-way merges)
git branch --merged = see branches merged into the current branch
git branch -d (branch-name) = delete a branch, only if already merged
git branch -D (branch-name) = delete a branch, including if not already merged (exercise caution here)
git merge --abort = abort a merge during a merge conflict situation
git checkout (commit-hash) = checkout a commit directly, not through a branch, results in a detached HEAD state
git stash = create a stash point
git stash list = list stash points
git stash list -p = list stash points and show diffs per stash
git stash apply = apply most recent stash
git stash pop = apply most recent stash, and remove it from saved stashes
git stash apply (stash reference) = apply a specific stash point
git stash save "(description)" = create a stash point, be more descriptive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment