Skip to content

Instantly share code, notes, and snippets.

@irace
Last active October 8, 2015 17:38
Show Gist options
  • Save irace/3366283 to your computer and use it in GitHub Desktop.
Save irace/3366283 to your computer and use it in GitHub Desktop.
Git cheat sheet
# Checkout remote branch
git checkout -t origin/<branch>
# Delete branch (local, remote)
git branch -d <branch>
git push origin --delete <branch>
# Tagging
git fetch --tags [email protected]:jstn/JXHTTP.git
git tag -f 1.0.0 # Move a tag to the latest commit
git push origin 1.0.0
# Remove local commits
git reset --soft HEAD^ # Keep changes
git reset --hard HEAD^ # Toss changes
# Delete a remote tag
git tag -d 12345
git push origin :refs/tags/12345
# Submodules
git submodule init
git submodule update
# Merge upstream changes into forked repository
git remote add upstream git://github.com/jstn/JXHTTP.git
git pull upstream master
# Reset forked repository
git remote add upstream git://github.com/jstn/JXHTTP.git
git fetch upstream
git reset --hard upstream/master
git push --force
# Remove local commits
git reset --hard origin/master
# Ignore changes in tracked files
git update-index --assume-unchanged <file>
git update-index --no-assume-unchanged <file>
# Add support for Localizable.strings
*.strings diff=localizablestrings # .git/info/attributes
[diff "localizablestrings"] # ~/.gitconfig
textconv = "iconv -f utf-16 -t utf-8"
# Configure GitHub with SSH public keys
git clone [email protected]:irace/webzap.git
ssh-keygen
cat id_rsa.pub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment