aboutsummaryrefslogtreecommitdiff
path: root/base/gitconfig
blob: 2a9996a89484d7ba9fc13e528af53859b533d874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
[user]
  name = Alexis Hovorka
  email = alexisspacegirl@gmail.com
  #signingkey =
[github]
  user = alexisspacegirl
[url "https://github.com/"]
  insteadOf = gh:
[url "https://gist.github.com/"]
  insteadOf = gist:
[url "https://gitlab.com/"]
  insteadOf = gl:
[url "https://bitbucket.org/"]
  insteadOf = bb:
[url "git.ahov.co:"]
  insteadOf = ahov:

[core]
  editor = vim
  excludesfile = ~/.gitignore_global
[init]
  defaultBranch = main
[commit]
  template = ~/.gitmessage
[credential]
  helper = cache --timeout 3600
[merge]
  tool = vimdiff
[push]
  default = simple
[pull]
  rebase = false
#  ff = only
#[rerere]
#  enabled = 1
#  autoupdate = 1
#[status]
#  submoduleSummary = true

[color]
  ui = true
[color "branch"]
  current = yellow reverse
  local = green
  remote = red
[color "diff"]
  meta = black bold
  frag = magenta
  old = red
  plain = white
  new = green
  whitespaces = red reverse
[color "status"]
  added = green
  changed = yellow
  untracked = red

[alias]
  new = "!git init && git symbolic-ref HEAD refs/heads/main"
  this = !bash -c 'git root &>/dev/null && echo "Already a git repository" || (git new && git add . && git commit -m \"Initial commit\")'
  root = rev-parse --show-toplevel
  cloner = clone --recursive
  rv = remote -v

  h = "!f() { git log $* | grep '^commit ' | cut -d' ' -f2; }; f" # Return a list of commit SHA1s
  details = log -n1 -p --format=fuller # View the log and diff for a commit (previous if no SHA1 provided)
  churn = !git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN {print "count,file"} {print $1 "," $2}'
  hashlength = "!f() { git log --graph --topo-order --pretty='%h' $* | wc -L; }; f"
  namelength = "!f() { git log --pretty='%an' $* | wc -L; }; f"
  l = "!f() { git log --graph --topo-order --boundary --date=short --pretty=\"%>|($(git hashlength $*))%C(1)%h%Creset %C(2)%cd%Creset %<($(git namelength $*))%C(4)%an%Creset │ %s%C(16)%d%Creset\" $*; }; f"
  la = !git l --all
  ll = log --decorate --stat
  lp = log --patch
  d = diff            # Current vs added
  dc = diff --cached  # Added vs committed

  b = checkout -b
  co = checkout
  com = checkout master
  pullr = pull --rebase
  ra = rebase --abort
  rc = rebase --continue
  squash = rebase -i
  br = branch -a
  bv = branch -av
  bd = branch -d

  fetchp = fetch --prune
  fetcha = fetch --all
  mergef = merge --ff-only

  s = stash # --keep-index || -u [-a] || --patch (interactive)
  sl = stash list
  sp = stash push
  sd = stash drop
  sa = stash apply
  sb = stash branch
  poop = stash pop

  rmd = !git ls-files -z --deleted | xargs -0 git rm  # Remove deleted files
  addremove = !git rmd && git add . --all             # Add and remove all changes
  hard = reset --hard origin/master
  unstage = reset HEAD --

  pushallmaster = !git remote | xargs -L1 -I REMOTE git push REMOTE master
  pushm = !git pushallmaster
  pushf = push --force-with-lease # safe force pushing
  pushfm = !git pushm --force-with-lease

  export = archive -o latest.tar.gz -9 --prefix=latest/ # Save a repo as a tarball; git export master
  amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend # Same message, but include more added files
  trim = !git reflog expire --expire=now --all && git gc --prune=now # Thin out older metadata, reduce filesystem footprint

  spull = !git pull && git submodule sync --recursive && git submodule update --init --recursive
  sspull= !git pull && git submodule update --init --recursive --remote
  sfetch = submodule foreach 'git fetch --all'

  brlocaloneline = !git branch | grep -v \\* | xargs
  brdeletelocal = !git branch -D `git brlocaloneline` || echo "Nothing to delete"
  brallfromremotes = !git branch -a | grep 'remotes/' | grep -v "HEAD" | sed 's/remotes\\///'
  brcreatefromremotes = !git brallfromremotes | xargs git branch
  sync = !git checkout master && git brdeletelocal && git fetch --all
  # https://stackoverflow.com/questions/10610327/delete-all-local-git-branches#10610669