Cheat Sheet - GIT

Cheat Sheet - GIT


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 


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>


Abort a merge process

git merge --abort


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


Sync a forked repository

Git Flow CheatSheet


Delete local & remote repository

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

Push an existing repository

git remote add origin  
git push -u origin --all  

Deleting the entire commit history

# Checkout
git checkout --orphan latest_branch 

# Add all files
git add -A 

# Commit changes
git commit -am "initial commit" 

# Delete branch
git branch -D main 

# Rename current branch 
git branch -m main 

# Force update repository
git push -f origin main