Skip to content

Instantly share code, notes, and snippets.

@martinratinaud
Last active August 24, 2023 07:06
Show Gist options
  • Save martinratinaud/f1097b9b6905f1e70036adbdf9380a55 to your computer and use it in GitHub Desktop.
Save martinratinaud/f1097b9b6905f1e70036adbdf9380a55 to your computer and use it in GitHub Desktop.
Awesome Git Configuration
[alias]
# shortcuts
c = commit
co = checkout
cp = cherry-pick
f = fetch
# enhancements
d = diff -- ':!package-lock.json' ':!yarn.lock' # Do not show lock files when diffing
ds = diff --staged -- ':!package-lock.json' ':!yarn.lock' # Do not show lock files when diffing staged files
b = branch -avv # Show all branches
pf = push --force-with-lease # checks if the remote version of the branch is the same as the one you rebase or fail
# Display lot better logs
l = log --graph --oneline --all
lg = log --pretty=tformat:'%Cred%h%Creset %C(bold blue)<%an>%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)%ad%Creset' --color --graph --abbrev-commit --date=default --decorate
# history
default = !"git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'"
hist = "!if [[ $(git rev-parse --abbrev-ref HEAD) != $(git default) ]]; then git lg HEAD --not $(git default); else git lg -18; fi;" # get all commits that are not in default branch
h = !"git hist"
[core]
editor = nano # Use nano instead of less
pager = cat # Do not page and show content straigt in the console
excludesfile = ~/.gitignore_global # For files you always want to ignore
ignorecase = false # work better on filesystems that are not case sensitive
[rebase]
autosquash = true # rebase --interactive will automatically move 'fixup!' and 'squash!' commits
autostash = true # stash a dirty tree, rebase, then unstash
[rerere]
enabled = true # remember previous conflict resolutions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment