Git Tips
General
- Favor smaller, atomic commits
- If needed, fixup history before pushing
git rebase -igit commit --amend --no-edit, optionally--reset-authorto reset date
Aliases
This is a useful visualization I use all the time:
alias.lg=log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%C(bold)%d%Creset %s %C(brightgreen)(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --branches
This is niche but potentially interesting:
alias.sizeof=ls-tree -r -l HEAD --
Scenarios
In the event you have commits on main which should be a topic branch
git switch -c topicgit switch -C main origin\main- Or, if you also want to be up to date, you could do
git fetch origin main:mainand thengit rebase main
- Or, if you also want to be up to date, you could do
In the event you determined you had the wrong value of core.autocrlf, changed it, and need to apply the change to all files
- Make sure there are no important uncommited changes
- If there are, maybe use
git add --renormalize
- If there are, maybe use
git read-tree --emptygit reset --hard