til/Applications/Essential/git.md

798 B

Git

Config

Aliases:

git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.df diff
git config --global alias.st status
git config --global alias.logo 'log --pretty=oneline'

Use neovim when commit:

git config --global core.editor nvim

Commands

Prefer rebase when pull:

git pull --rebase

Clean outdated branches:

git fetch --prune

Push force safely:

git push --force-with-lease

Rewrite history by changing last x commits :

git rebase -i HEAD~x

Squash last x commits to 1 commit:

git reset HEAD~x
git add -A
git commit

Cleanup unnecessary files:

git gc

Find common ancestor:

git merge-base A B