Created
November 4, 2024 02:05
-
-
Save eliaskanelis/a4dd809bb66b32e1e96eaeb29cc28497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
email = [email protected] | |
name = Kanelis Elias | |
[init] | |
defaultBranch = master | |
[core] | |
editor = emacsclient -t -create-frame --alternate-editor= | |
quotepath = false | |
pager = diff-so-fancy | less --tabs=4 -RF | |
# pager = delta | |
[color] | |
ui = true | |
[color "decorate"] | |
branch = green bold | |
remoteBranch = cyan bold | |
tag = yellow bold | |
HEAD = red bold | |
[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 | |
[diff-so-fancy] | |
markEmptyLines = false | |
changeHunkIndicators = false | |
stripLeadingSymbols = false | |
useUnicodeRuler = false | |
rulerWidth = 80 | |
[delta] | |
# use n and N to move between diff sections | |
navigate = true | |
side-by-side = true | |
[interactive] | |
diffFilter = diff-so-fancy --patch | |
# diffFilter = delta --color-only | |
[alias] | |
## ------------------------------------------------------------------------ | |
# Extract info (useful for use by other aliases and rather for direct use) | |
# Get the default branch of the repo | |
get-default-branch = symbolic-ref --short -q refs/remotes/origin/HEAD | |
# Get the merge base between the default branch of the repo and a given branch/tag/commit hash | |
get-default-branch-merge-base-from = !git merge-base $(git get-default-branch) | |
## ------------------------------------------------------------------------ | |
# Formatting | |
# Pretty formats the git log as one line | |
log-pretty-oneline = log --format=format:'%C(bold yellow)%h%C(reset) %C(bold green)%<(21,trunc)%cr%C(reset) %C(white)%<(30,trunc)%s%C(reset) %C(dim white) %<(15,trunc)%an%C(reset)%C(auto)%D%C(reset)' | |
# Pretty formats the git log as multiply lines | |
log-pretty-multiline = log --pretty=format:'%C(bold yellow)%h%C(reset) %C(green)%<(50,trunc)%s%C(reset) %C(auto)%D%C(reset)%n %C(bold white)%<(21,trunc)%cr%C(reset) %an' | |
# Pretty log (most common choice) | |
l = log-pretty-oneline --abbrev-commit --decorate --color=always | |
## ------------------------------------------------------------------------ | |
# Log | |
# Show logs starting the HEAD or given input | |
# TODO | |
# lp = l --graph --first-parent | |
lp = !git l --graph --first-parent --ancestry-path $(git get-default-branch)^... | |
l-all = !git lga --ancestry-path $(git get-default-branch)^... | |
l-min = !git lga --first-parent --simplify-by-decoration --ancestry-path $(git get-default-branch)^... | |
# Minimal log betweem | |
lm = lp --simplify-by-decoration | |
# Show commit logs in a graph | |
lg = l --graph | |
# Show all commit logs regardless user input | |
lga = lg --all | |
# Show sane log of ONLY (except if arguments given): | |
# Show sane log of ONLY: | |
# 1. Your HEAD | |
# 2. The default branch of the repo | |
# 3. The last tag | |
lw = "!f() { \ | |
ref1=${1:-HEAD}; \ | |
default=${2:-$(git get-default-branch)}; \ | |
base=$(git merge-base --octopus ${ref1} ${default}); \ | |
common=$(git merge-base --octopus ${ref1} ${base}^); \ | |
echo ref1 = ${ref1}; \ | |
echo default = ${default}; \ | |
echo base = ${base}; \ | |
echo common = ${common}; \ | |
echo git lg ${common}..${ref1} ${common}..${default}; \ | |
git lg ${common}..${ref1} ${common}..${default}; \ | |
}; f" | |
# Show sane log of ONLY: | |
# 1. Your local branches | |
# 2. The default branch of the repo | |
# 3. The last tag | |
lwa = "!f() { \ | |
cmd='git lg --first-parent --simplify-by-decoration '; \ | |
tags="$(git describe --tags --abbrev=0)"; \ | |
branches="$(git branch --no-color --format='%(refname:short)')"; \ | |
references=\"${branches} ${tags}\"; \ | |
default=$(git get-default-branch); \ | |
base=$(git merge-base --octopus ${references} ${default}); \ | |
common=$(git merge-base --octopus ${references} ${base}^); \ | |
echo default = ${default}; \ | |
echo base = ${base}; \ | |
echo common = ${common}; \ | |
for reference in ${references}; do \ | |
cmd=\"${cmd} ${common}..${reference}\"; \ | |
done; \ | |
echo "${cmd}"; \ | |
eval "${cmd}"; \ | |
}; f" | |
## ------------------------------------------------------------------------ | |
# Basic | |
# Minimal status | |
s = status --short | |
st = status | |
co = checkout --recurse-submodules | |
ci = commit --verbose | |
dt = difftool --dir-diff --no-symlinks | |
## ------------------------------------------------------------------------ | |
## Show things | |
# Show details about a specific stash | |
ss = stash show --color=always --patch | |
## ------------------------------------------------------------------------ | |
## List things | |
# List branches | |
lbranch = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)%(committerdate:relative)%(color:reset) %(authorname)' --sort=-committerdate --color | |
# List stashes | |
lstash = stash list --format='%C(red)%h%C(reset) | %C(green)%gd%C(reset) | %C(blue)%cs%C(reset) | %gs' --color | |
# List tags | |
ltag = tag --list --format='%(HEAD) %(color:green)%(refname:short)%(color:reset) %(contents:subject) %(color:cyan)%(taggername)%(color:reset) %(color:green)%(taggerdate:short)%(color:reset)' --color | |
## ------------------------------------------------------------------------ | |
## Custom workflow | |
# Compare HEAD with default origin branch | |
# TODO: Is this stable? Will it find develop at work? | |
# dp = !git dt $(git merge-base HEAD origin/master) | |
dp = !git dt $(git get-default-branch-merge-base-from HEAD) | |
## ------------------------------------------------------------------------ | |
## Fuzzy | |
# Checkout to a branch | |
fco-branch = !git lbranch | grep -ve '^*' | fzf --no-sort --ansi --preview='git l {1}' | xargs --no-run-if-empty sh -c 'git co $0' | |
# Checkout to a commit | |
fco-commit = !git l | fzf --no-sort --ansi --preview='git show --color {1}' | xargs --no-run-if-empty sh -c 'git co $0' | |
# Checkout to a tag | |
fco-tag = !git ltag | fzf --no-sort --ansi --preview='git show --color {1}' | xargs --no-run-if-empty sh -c 'git co $0' | |
# Fuzzy checkout (most common choice) | |
fco = fco-branch | |
# Open difftool with a local branch | |
fdt = !git lbranch | grep -ve '^*' | fzf --no-sort --ansi --preview='git l {1}' | xargs --no-run-if-empty sh -c 'git dt $0' | |
# Open difftool with local or remote branch | |
fdta = !git lbranch --all | grep -ve '^*' | fzf --no-sort --ansi --preview='git l {1}' | xargs --no-run-if-empty sh -c 'git dt $0' | |
# Compare branch with merge base of default origin branch | |
fdp-branch = "!git lbranch | sed 's/^[[:space:]]*\\* //; s/^[[:space:]]*//' | fzf --no-sort --ansi --preview='git l {1}' | xargs --no-run-if-empty sh -c 'git dp $0'" | |
# Compare commit with merge base of default origin branch | |
fdp-commit = "!git l | sed 's/^[[:space:]]*\\* //; s/^[[:space:]]*//' | fzf --no-sort --ansi --preview='git l {1}' | xargs --no-run-if-empty sh -c 'git dp $0'" | |
# Fuzzy compare with merge base of default origin branch (most common choice) | |
fdp = fdp-branch | |
# Apply a stash from list | |
fsa = !git lstash | fzf --no-sort --ansi --preview='git ss {1}' | xargs --no-run-if-empty bash -c 'git stash apply $2' | |
# Drop a stash from list | |
fsd = !git lstash | fzf --no-sort --ansi --preview='git ss {1}' | xargs --no-run-if-empty bash -c 'git stash drop $2' | |
## ------------------------------------------------------------------------ | |
# Pull request | |
# Fetch and checkout a PR | |
prf = "!f() { \ | |
branchName=\"pr-$1\"; \ | |
git fetch origin pull/$1/head:${branchName} && git co ${branchName}; \ | |
}; f" | |
# Fuzzy fetch and checkout a PR | |
fprf = !git ls-remote origin 'pull/*/head' | awk -F'/' '{print $3}' | fzf --no-sort --ansi | xargs --no-run-if-empty bash -c 'git pfr $1' | |
## ------------------------------------------------------------------------ | |
# Experiemental | |
lf = !fzf --no-sort --ansi --preview='git l --follow {1}' | xargs --no-run-if-empty sh -c 'git l --follow $0' | |
test = !git l --follow tests.mk | fzf --no-sort --ansi --preview='git show --color=always ${1} -- tests.mk | diff-so-fancy' | |
test2 = !git l --follow tests.mk | fzf --no-sort --ansi --preview='git diff --color=always ${1}^! -- tests.mk | diff-so-fancy' | |
s-experimental = status --show-stash --ahead-behind --untracked-files=all -M --branch | |
d = diff --minimal --find-renames --ignore-all-space --ignore-blank-lines --color-words | |
d2 = diff --find-renames --ignore-all-space --ignore-blank-lines --color --word-diff --stat --unified=10 | |
# Search within commits: e.g: git se "text_to_search" | |
se = !git rev-list --all | xargs git grep -F | |
# Save my work in a commit | |
save = !git add -A && git commit -m 'WIP: Untested work in progress served as a save point' | |
filelog = "!f() { git log --pretty=format:\"%h - %an, %ar : %s\" --follow -- $1 | fzf --ansi --preview=\"git show --color=always {1}\" | less -R; }; f" | |
clean-reset = "!f() { \ | |
git clean -ffdx && \ | |
git reset --hard HEAD && \ | |
git submodule foreach --recursive 'git clean -ffdx && git reset --hard HEAD'; \ | |
}; f" | |
## Used during merge | |
ours = "!f() { git co --ours $@ && git add $@; }; f" | |
theirs = "!f() { git co --theirs $@ && git add $@; }; f" | |
## pick = "!sh -c 'git stash show -p \"${1:-$(git stash list --format=\"%h\" | fzf)}\"' -" | |
# Log commits and stases | |
## logall = "!sh -c 'git lg && echo && git stash list --oneline'" | |
[diff] | |
tool = bc4 | |
guitool = bc4 | |
[difftool] | |
prompt = false | |
[difftool "meld"] | |
cmd = meld "$LOCAL" "$REMOTE" | |
[difftool "bc4"] | |
cmd = bcompare "$LOCAL" "$REMOTE" | |
trustExitCode = true | |
[merge] | |
# tool = meld | |
tool = bc4 | |
conflictstyle = diff3 | |
[mergetool "meld"] | |
trustExitCode = true | |
[mergetool "bc4"] | |
trustExitCode = true | |
[web] | |
browser = firefox | |
[instaweb] | |
port = 4000 | |
browser = firefox |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment