Skip to content

Instantly share code, notes, and snippets.

@jmetzz
Last active April 11, 2024 15:01
Show Gist options
  • Save jmetzz/1d3a038341d8d17cb750 to your computer and use it in GitHub Desktop.
Save jmetzz/1d3a038341d8d17cb750 to your computer and use it in GitHub Desktop.
My git config
[user]
name = Your name
email = your.email@domain.com
[alias]
# List branches
br = branch
# Commit changes
ci = commit
# Clone a repository
cl = clone
# Switch branches (updated from checkout to switch)
co = switch
# Apply the changes introduced by some existing commits
cp = cherry-pick
# Show the working tree status in short format
st = status -s
# Show log in a custom format highlighting commit hash, decoration, message, and author
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
# Similar to 'ls' but includes number of insertions and deletions
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
# Show log with short dates
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
# Show log with relative dates
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
# Show log as a graph
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
# Log graph of commits in one line
lol = log --graph --decorate --pretty=oneline --abbrev-commit
# Log graph of all commits in one line, including remotes
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
# List symlinks in the repository
ls-symlinks = !git ls-files -s -v | awk '/120000/{print $1,$2,$5}'
# List all symlinks in all repositories listed in a text file
ls-all-symlinks = "!__git_ls_all_symlinks (){\n for repo in $(cat $OOBS_VAR/repos-with-symlinks.txt); do\n if [[ -d ${REPO_WORKAREA}/${repo} ]]; then\n pushd ${REPO_WORKAREA}/${repo}\n git ls-symlinks\n popd\n fi\n done\n}; __git_ls_all_symlinks"
# Show diff of what is staged but not yet committed
staged = diff --cached
# Show only the names of files that are staged
staged-files = diff --cached --name-only
# Show diff with word differences highlighted
diff = diff --word-diff
# Show the last commit log with numstat
last-stats = "!git ll -1"
# Show the last commit details
last = log -1 HEAD
# Show diff of what's changed since the last commit
since-last = diff --cached HEAD^
# Unstage files (alternative to 'git restore --staged <file>')
# removes changes from the staging area (index) without discarding the modifications in your working directory
unstage = restore --staged --
# Reset current HEAD to the specified state, unstaging staged changes without discarding work
r = reset
# Undo the last commit, keeping changes in the working directory
r1 = reset HEAD^
# Undo the last two commits, keeping changes in the working directory
r2 = reset HEAD^^
# Discard all changes in the working directory and staging area
rh = reset --hard
# Discard all changes in the working directory and staging area, reverting to the state before the last commit
rh1 = reset HEAD^ --hard
# Discard all changes in the working directory and staging area, reverting to the state before the last two commits
rh2 = reset HEAD^^ --hard
[init]
defaultBranch = main
[branch]
autosetuprebase = always
[pull]
rebase = true
[push]
autoSetupRemote = true
[rebase]
stat = true
[diff]
renameLimit = 30000
[color]
ui = true
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
[color "diff"]
meta = 11
frag = magenta bold
func = 146 bold
commit = yellow bold
old = red bold
new = green bold
whitespace = red reverse
[core]
autocrlf = input
filemode = false
symlinks = true
excludesfile = ~/.gitignore_global
pager = diff-so-fancy | less --tabs=4 -RFX
[interactive]
diffFilter = diff-so-fancy --patch
[merge]
renameLimit = 30000
conflictstyle = diff3
[rerere]
# short for "reuse recorded resolution", helps to manage the resolution of merge conflicts.
enabled = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment