Skip to content

Instantly share code, notes, and snippets.

@anselmdk
Last active November 14, 2016 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anselmdk/168ea3b7a5c9b5dffd80 to your computer and use it in GitHub Desktop.
Save anselmdk/168ea3b7a5c9b5dffd80 to your computer and use it in GitHub Desktop.
Git Cheat Sheet

Branches

Deletion

git branch -d local-branch

Git Cheat Sheet

Stashing

git stash
git stash list
git stash apply

Tagging

List tags: git tag
Show tag info: git show releaseX
Create tag: git tag -a releaseX -m 'Short description'
Push tag: git push origin releaseX

Deleting a tag: git tag -d old

Nice release log

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

Submodules

#one-line updater (recursive)
git submodule update --init --recursive

# Remove git submodules once and for all
git rm --cached path/to/submodule

# move submodule
git mv old/submod new/submod
#make sure needed directories exist

Remotes

Set url

git remote set-url --push origin git@github.com:User/forked.git

Delete untracked files

#check what will be removed
git clean -fd -n

#remove
git clean -fd

Line endings

Read more here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment