aboutsummaryrefslogtreecommitdiffstats
path: root/home/sadbeast/features/git.nix
blob: d4d588c2717761af1faacdc301393883a2b14245 (plain) (blame)
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
{
  config,
  lib,
  ...
}: {
  programs.git = {
    enable = true;
    userName = lib.mkDefault config.home.username;
    userEmail = lib.mkDefault "sadbeast@sadbeast.com";

    aliases = {
      p = "pull --ff-only";
      ff = "merge --ff-only";
      graph = "log --decorate --oneline --graph";
      add-nowhitespace = "!git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero -";
      # for "last branch", shows the most recently accessed branches
      lb = "!git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 15 | awk -F' ~ HEAD@{' '{printf(\"  \\033[33m%s: \\033[37m %s\\033[0m\\n\", substr($2, 1, length($2)-1), $1)}'";
    };

    extraConfig = {
      init.defaultBranch = "main";
      push.autoSetupRemote = true;
      # Reuse merge conflict fixes when rebasing
      rerere.enabled = true;
    };
    ignores = [".direnv"];

    lfs.enable = true;
  };
}