Skip to content

Instantly share code, notes, and snippets.

@rajasharan
Last active March 8, 2019 19:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajasharan/79d330feea0fec336310569e2bba380c to your computer and use it in GitHub Desktop.
Save rajasharan/79d330feea0fec336310569e2bba380c to your computer and use it in GitHub Desktop.
common git commands I usually use

Always double check remotes

git remote -v

Always track remotes

git branch -u <remote>/<branch>

Always fetch before status

git fetch --all
git status
git dsf
git dsf --cached

Always fetch & merge, don't pull (gives opportunity to verify incoming changes)

git fetch --all
git dsf ..<remote>/<branch>
git merge <remote>/<branch>

Always push using full syntax (<source-branch>:<dest-branch>)

git remote -v
git push <remote> HEAD:<branch>

Sometimes amend

git log -3
git commit --amend
git log -3

Sometimes reset and cherry-pick

git reset --hard <remote>/<branch>
git cherry-pick <commit>

Always stash

git stash save -u[--include-untracked]
git stash save -k[--keep-index]
git stash apply
git stash drop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment