X-Git-Url: https://git.phdru.name/?p=dotfiles.git;a=blobdiff_plain;f=.gitconfig;h=9e3e776bd021a4cb8f02e55c5f0b5d00a7773d6e;hp=38d9c5c93eaa567bf3ea74cc6c00ac4c8b98e073;hb=HEAD;hpb=6c33565fed35bc03f7a61fd7ecb41558cc59a988 diff --git a/.gitconfig b/.gitconfig index 38d9c5c..e38baa0 100644 --- a/.gitconfig +++ b/.gitconfig @@ -1,16 +1,161 @@ [alias] - b = branch - branches = branch -a - camend = commit --amend -C HEAD +# I copied some aliases from http://gitalias.com/ and other sources. +# Some I've added to gitalias. Some are mine. + + # One letter alias for our most frequent commands. + a = add + b = branch + c = commit + d = diff + f = fetch + g = grep + l = log + m = merge + o = checkout + p = pull + r = remote + s = status + w = whatchanged + + ### add ### + + aa = add --all + + ap = add --patch + + au = add --update + + ### branch ### + + be = branch --edit-description + + bm = branch --merged + + bnm = branch --no-merged + + ### commit ### + + cm = commit --message + + ### checkout ### + + co = checkout + + ### cherry-pick ### + + chp = cherry-pick + + ### diff ### + + # diff - show changes not yet staged + dc = diff --cached + + # diff - changes about to be commited + ds = diff --staged + + # diff - show changes but by word, not line + dw = diff --word-diff + + ### rebase ### + + rb = rebase + + rba = rebase --abort + + rbc = rebase --continue + + rbs = rebase --skip + + # See https://blog.filippo.io/git-fixup-amending-an-older-commit/ + # This is a slightly modified version + fixup = "!f() { TARGET=$(git rev-parse \"$1\"); git commit --fixup=$TARGET && GIT_EDITOR=true exec git rebase --interactive --autostash --autosquash $TARGET~; }; f" + + ### remote ### + + rs = remote show + + ru = remote update + + rp = remote prune + + incoming = !git remote update --prune; exec git log ..@{upstream} + outgoing = log @{upstream}.. + + # Push to all remotes + push-to-all-remotes = !git remote | xargs -I% -n1 git push % + + ### show-branch ### + + # show-branch - print a list of branches and their commits. + sb = show-branch + + ### status ### + + ss = status --short + + ssb = status --short --branch + + aliases = "!git config --get-regexp '^alias\\.' | cut -c7- | sed 's/ / = /'" + + add-alias = "!f() { [ $# = 3 ] && git config $1 alias.\"$2\" \"$3\" && return 0 || echo \"Usage: git add-(local|global)-alias \" >&2 && return 1; }; f" + add-global-alias = "!exec git add-alias --global" + add-local-alias = "!exec git add-alias --local" + + # Last tag in the current branch + lasttag = describe --tags --abbrev=0 + + # Latest annotated tag in all branches + lasttagged = !exec git describe --tags `exec git rev-list --tags --max-count=1` + + # List all tags + tags = tag --list -n1 + + # Find text in any commit ever + grep-all = !"f() { git rev-list --all | xargs git grep \"$@\"; }; f" + + # Edit all files of the given type + edit-cached = !"f() { git ls-files --cached | sort -u ; }; exec `exec git var GIT_EDITOR` `f`" + edit-deleted = !"f() { git ls-files --deleted | sort -u ; }; exec `exec git var GIT_EDITOR` `f`" + edit-others = !"f() { git ls-files --others | sort -u ; }; exec `exec git var GIT_EDITOR` `f`" + edit-ignored = !"f() { git ls-files --ignored | sort -u ; }; exec `exec git var GIT_EDITOR` `f`" + edit-killed = !"f() { git ls-files --killed | sort -u ; }; exec `exec git var GIT_EDITOR` `f`" + edit-modified = !"f() { git ls-files --modified | sort -u ; }; exec `exec git var GIT_EDITOR` `f`" + edit-stage = !"f() { git ls-files --stage | cut -f2 | sort -u ; }; exec `exec git var GIT_EDITOR` `f`" + + # Editing and adding conflicted files: when we get many merge conflicts + # and want to quickly solve them using an editor, then add the files. + edit-unmerged = !"f() { git ls-files --unmerged | cut -f2 | sort -u ; }; exec `exec git var GIT_EDITOR` `f`" + add-unmerged = !"f() { git ls-files --unmerged | cut -f2 | sort -u ; }; exec git add `f`" + + # Get the current branch name + branch-name = rev-parse --abbrev-ref HEAD + + assume = update-index --assume-unchanged + unassume = update-index --no-assume-unchanged + # assume-all = "!git st -s | awk {'print $2'} | xargs git assume" + unassume-all = "!git assumed | xargs git update-index --no-assume-unchanged" + assumed = !"git ls-files -v | grep ^h | cut -c 3-" + + stashes = stash list + + branches = branch --all + ca = commit --all + cv = commit --verbose + cav = commit --all --verbose + cane = commit --amend --no-edit checkin = commit ci = commit - co = checkout - d = diff - dc = diff --cached - dshow = show --decorate - l = log --decorate + cat = cat-file -p + dh = "!f() { git -c color.diff=always diff \"$@\" | perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight | less; }; f" + dir = rev-parse --git-dir + dump = cat-file -p + file = cat-file -t + type = cat-file -t + ff = merge --ff-only + #git = !exec git l1 = log --decorate --oneline l5 = log --decorate -5 + ld = log --decorate lg = log --decorate --graph lg1 = log --decorate --graph --oneline lg5 = log --decorate --graph -5 @@ -18,16 +163,28 @@ lr1 = log --decorate --reverse --oneline lr5 = log --decorate --reverse -5 null-merge = merge --strategy=ours - remotes = remote -v - ri = "!sh -c 'git rebase --interactive --autosquash --preserve-merges ${1:-\"@{u}\"}' -" + rbi123 = "!f() { exec git rebase --interactive --autostash $1 $2 ${3:-\"@{upstream\\}\"}; }; f" + rbi = !exec git rbi123 '' '' + rbia = !exec git rbi123 --autosquash '' + rbiap = !exec git rbi123 --autosquash --preserve-merges + rbip = !exec git rbi123 '' --preserve-merges + remotes = remote --verbose + #root = !exec pwd root = rev-parse --show-toplevel - #root = !pwd + status = status --no-short st = status --short stb = status --short --branch - tags = tag -l + sd = show --decorate + sw = show --word-diff --decorate unstage = reset HEAD -- - wdiff = diff --word-diff - wshow = show --word-diff --decorate + + # Github: pull request, Gitlab: merge request + mpr = "!f() { git fetch ${2:-origin} refs/$3/$1/head:pr/$1 && if [ \"$4\" = checkout ]; then git checkout pr/$1; fi; }; f" + fetch-mr = "!f() { git mpr $1 ${2:-origin} merge-requests; }; f" + merge-request = "!f() { git mpr $1 ${2:-origin} merge-requests checkout; }; f" + fetch-pr = "!f() { git mpr $1 ${2:-origin} pull; }; f" + pull-request = "!f() { git mpr $1 ${2:-origin} pull checkout; }; f" + clean-pr = "!git checkout master ; git for-each-ref refs/heads/pr/* --format=\"%(refname)\" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done" [branch] autosetuprebase = always @@ -35,11 +192,21 @@ [color] ui = auto +[diff] + indentHeuristic = true + +[grep] + fallbackToNoIndex = true + [include] path = ~/lib/config/git/light_bg +[init] + defaultBranch = master + [log] abbrevCommit = true + #mailmap = true [merge] tool = vimdiff @@ -49,8 +216,30 @@ # 3 way diffs # cmd = vim -d \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\" -c \"wincmd J\" +[push] + default = simple + followTags = true + recurseSubmodules = check + [receive] - denyNonFastForwards = true + #denyCurrentBranch = updateInstead + denyDeleteCurrent = true + #denyDeletes = true + #denyNonFastForwards = true + +#[tag] +# sort = version:refname + +[tar "tar.bz2"] + command = bzip2 -c +[tar "tar.xz"] + command = xz -c + +#[transfer] +# fsckObjects = true + +[user] + signingKey = 6E080B70B6287B03 [web] browser = webbrowser @@ -61,3 +250,38 @@ [gui] fontui = -family \"DejaVu Sans\" -size 18 -weight normal -slant roman -underline 0 -overstrike 0 fontdiff = -family \"DejaVu Sans Mono\" -size 18 -weight normal -slant roman -underline 0 -overstrike 0 + +# git:// protocol fixers +#[url "https://github.com/"] +# insteadOf = "git://github.com/" +#[url "https://gist.github.com/"] +# insteadOf = "git://gist.github.com/" +#[url "ssh://git@github.com/"] +# insteadOf = "git://github.com/" +#[url "ssh://git@gist.github.com/"] +# insteadOf = "git://gist.github.com/" +#[url "https://gitlab.com/"] +# insteadOf = "git://gitlab.com/" +#[url "https://gist.gitlab.com/"] +# insteadOf = "git://gist.gitlab.com/" +#[url "ssh://git@gitlab.com/"] +# insteadOf = "git://gitlab.com/" +#[url "ssh://git@gist.gitlab.com/"] +# insteadOf = "git://gist.gitlab.com/" + +# Protocol changers +#[url "https://github.com/"] +# insteadOf = ssh://github.com/ +# insteadOf = ssh://git@github.com/ +# insteadOf = git@github.com: + +#[url "ssh://git@github.com/"] +# insteadOf = https://github.com/ + +#[url "https://gitlab.com/"] +# insteadOf = ssh://gitlab.com/ +# insteadOf = ssh://git@gitlab.com/ +# insteadOf = git@gitlab.com: + +#[url "ssh://git@gitlab.com/"] +# insteadOf = https://gitlab.com/