summaryrefslogtreecommitdiff
path: root/gitconfig
blob: 6cfc1dc7db02ee8d36aa51d18e407420ad6dff3a (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
[user]
  useConfigOnly = true
[push]
  default = simple
[alias]
  s = status
  a = add
  ap = add -p
  ps = push
  pl = pull
  cl = clone
  cr = clone --recursive
  cs = clone --single-branch --depth=1
  br = branch
  co = checkout
  ci = commit
  cm = commit -m
  ec = config --global --edit
  amend = commit -a --amend
  lt = log --graph --decorate --oneline --abbrev-commit --all
  ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
  ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
  le = log --oneline --decorate
  dl = "!git ll -1"
  df = diff
  dfs = diff --staged
  dfc = diff --cached
  ours = "!f() { git co --ours \"$@\" && git add \"$@\"; }; f"
  theirs = "!f() { git co --theirs \"$@\" && git add \"$@\"; }; f"
  sneak = "!f() { git commit --amend --no-edit "$@" && git push -f "$@"; }; f"
  test = "!echo \"$@\"; echo \"$@\""
  origin = remote show origin
  set-origin = remote set-url origin
  add-origin = remote add origin
  modpull = submodule update --remote --merge
  pruner = !"git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all"
  repacker = !git repack -a -d -f --depth=300 --window=300 --window-memory=1g
  optimize = !git pruner; git repacker; git prune-packed
  sm = submodule
  # submodule remove
  smrm = "!f(){\
    git submodule deinit -f \"$1\";\
    rm -rf .git/modules/\"$1\";\
    git rm -f \"$1\";\
  }; f"

  # These are *not* good practice for collaborative projects, but are fine
  # for repos that use git to submit settings, where most commit messages
  # would be "Added <user>"/"Removed <repo>" (I'm thinking of gitolite-admin).
  # Those repos are usually private and benefit from the faster commits,
  # while the changes are easily visible from the diff.
  # dated commit
  dcm = "!f(){ git commit -m \"$(date --iso-8601=seconds)\"; }; f"
  # dated push
  dps = "!f(){ git dcm; git push \"$@\"; }; f"

  # Set user information, supposed to be used once per local repo
  # Works better with user.useConfigOnly = true
  ident = "!f(){\
    git config --replace-all user.name \"$1\";\
    git config --replace-all user.email \"$2\";\
    if [ -n \"$3\" ]; then\
      git config --replace-all user.signingkey \"$3\";\
      git config --replace-all commit.gpgsign true;\
    fi;\
  }; f"

[color]
  ui = true