less than 1 minute read

# delete all local branches except master
git branch \| grep -v "master" \| xargs git branch -D

# on windows
git branch | select-string -NotMatch -Pattern "master" | %{ git branch -D $_.ToString().Trim() }

# rename branch
git branch -m feature/4810-feature-flag

# revert the file with the file from the master branch
git co master -- source/graphql/yarn.lock

# shallow clone, getting the latest copy of the relevant files, saving space and time
git clone --depth 1 [https://github.com/django/django.git](https://github.com/django/django.git)

# set VS Code as the default git editor
git config --global core.editor "code --wait"

# print public ssh key
cat ~/.ssh/id_rsa.pub

# delete the tag locally and remotely
git tag -d 9.9.0
git push --delete origin 9.9.0

# create a tag locally and remotely
git tag -am "9.9.0" 9.9.0
git push --tags

# reset to origin/HEAD leaving files uncommitted
git reset --mixed origin/HEAD

# to fix error: cannot lock ref ...
git remote prune origin

# reset local repository branch to remote repository HEAD
git fetch origin, git reset --hard origin/master

# list global config entries
git config --global --list

# edit global config file
git config --global --edit

Comments