Skip to content

Instantly share code, notes, and snippets.

@matthiasguentert
Last active March 14, 2022 19:46
Show Gist options
  • Save matthiasguentert/515b5e8d5410e536f69b04b1c1aef587 to your computer and use it in GitHub Desktop.
Save matthiasguentert/515b5e8d5410e536f69b04b1c1aef587 to your computer and use it in GitHub Desktop.
Git Cheat Sheet

Configuration

Edit via editor

# <project\.git\config 
git config --edit

# C:\Users\%username%\.gitconfig
git config --global --edit

# C:\Program Files\Git\etc\gitconfig
git config --system --edit 

Remotes

Show remotes

git remote -v 

Delete local references to remote branches that don't exist anymore

git remote prune origin

Set remote url

git remote set-url origin <url>

Merging

Abort a merge process

git merge --abort

Tags

Checkout Git Tag

git checkout tags/<tag> -b <branch>

Delete single tag

# delete remotely 
git push --delete origin v2.0.1
# delete locally 
git tag --delete v2.0.1

Delete all tags

# First delete remote tags
git tag -l | xargs git push --delete origin

# Then delete local tags 
git tag | xargs git tag -d

Misc

Sync a forked repository

https://gist.github.com/kayagultekin/557975964ae26b99b46be3082ee828cf

Git Flow CheatSheet

Link

Delete local & remote repository

git branch -d <branch_name>
git push <remote_name> --delete <branch_name>

Push an existing repository

git remote add origin https://github.com/gittower/example.git  
git push -u origin --all  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment