Skip to content

Instantly share code, notes, and snippets.

@PaulChana
Last active May 8, 2018 11:42
Show Gist options
  • Save PaulChana/9c4a3b4ce7a3d9e9e3cd032c103a4e87 to your computer and use it in GitHub Desktop.
Save PaulChana/9c4a3b4ce7a3d9e9e3cd032c103a4e87 to your computer and use it in GitHub Desktop.
Git cheatsheet #git
// Checkout branch and track remote
git checkout -b feature/project --track origin/feature/project
// Show current branch name
git rev-parse --abbrev-ref HEAD
// Show all local branches with your starred:
git branch
// Are we up to date with remote
git status -uno
// Add all files and commit
git add -A && git commit -m "Your Message"
// Commit add push
git add -A && git commit -m "Project update" && git push -u origin master
// Add with checks for the hunks
git add -p
// Add all and commit and push
git commit -am "Message" && git push
// Add submodule
git submodule add <PATH>
// Create and push branch
git checkout -b develop
git push -u origin develop
// Pull a repo
git pull --recurse-submodules --no-commit --rebase
// Recursive update of submodules
git submodule update --init --recursive
// Delete a tag from origin.
git tag -d 0.1.3
git push origin :refs/tags/0.1.3
// Replace entire folder with one from another branch.
git rm -r /path/to/folder
git checkout OTHER_BRANCH -- /path/to/folder
// Move a submodule
git mv old/submod new/submod
// List submodules
grep path .gitmodules | sed 's/.*= //'
// See file history
git log -p <FILENAME>
// Show contents of a stash
git stash show -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment