Config
git config merge.conflictstyle diff3
git config diff.wsErrorHighlight all
git config push.autoSetupRemote true
merge.conflictstyle diff3adds original code to the diff view, this helps arrive at correct resolution when resolving a conflictdiff.wsErrorHighlight allDisplays whitespace in diffpush.autoSetupRemote trueautomates the first push of a branch
Aliases
I feel at home with these aliases:
git config --global alias.st "status --short"
git config --global alias.last "log --stat -1 HEAD"
git config --global alias.ls "log --pretty=format:'%Cgreen %H %Creset%cr%Cred by %cn%Creset%n%s%n' --stat --graph"
git config --global alias.put "!git add .; git commit -m"
git config --global alias.branches "branch -avv --sort=-committerdate"
git config --global alias.diffs "diff -z --cached --color-moved"
git config --global alias.diffl "diff --color-moved HEAD~ HEAD"
git config --global alias.d "!git diff -z --color-moved --unified=0; echo 'Summary:'; git status --short"
git config --global alias.please "push --force-with-lease"
git config --global alias.pub "!f() { branch=$(git rev-parse --abbrev-ref HEAD); git push --set-upstream origin $branch; }; f"
The only thing to watch out for is that speedy git put eagerly commits all changes in the working tree, including any unexpected or overlooked changes.
Line endings
On Windows, convert CRLF to LF on commit, and LF to CRLF on checkout: bash
git config --global core.autocrlf true
On Linux, convert CRLF to LF on commit only, to fix any CLRF line endings: bash
git config --global core.autocrlf input
Prompt summary
On Windows, use PoshGit to provide tab-completion and show status summary in the terminal.
Tips
Miscellaneous notes.
Transition changes to my fork
git remote set-url origin <fork URL>
git fetch --all -p
To ignore a change to the file, and then undo it
git update-index --skip-worktree .gitignore
git update-index --no-skip-worktree .gitignore
To list all conflicts
git diff --name-only --diff-filter=U
Occasional manual cleanup (tip: run it on schedule)
git gc
git prune
git gc --aggressive