{
  pkgs,
  lib,
  config,
  ...
}: {
  programs.git = {
    enable = true;
    extraConfig = {
      rerere.enabled = true;
      rebase.updateRefs = true;
    };
    aliases = {
      ui = "!lazygit";
      graph = "log --oneline --all --graph";
      amend = "commit --amend --no-edit";
      sdiff = "diff --staged";
      fpush = "push --force-with-lease";
      t = "tag --annotate";
      bclone = "!sh ${pkgs.writeShellScriptBin "bare-clone" ''
        url=$1
        basename=''${url##*/}
        if [[ $2 == -* ]]
        then
          opts=''${@:2}
          name=''${basename%.*}
        else
          opts=''${@:3}
          name=''${2:-''${basename%.*}}
        fi

        mkdir "$name"

        git clone --bare "$url" "$name/.bare" $opts || {
          rm -r "$name"
          exit 1
        }

        cd "$name"
        echo "gitdir: ./.bare" > .git

        git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"

        git fetch origin $opts
      ''}/bin/bare-clone";
    };
    difftastic = {
      enable = true;
    };
  };

  programs.lazygit = {
    enable = true;
  };

  programs.jujutsu = {
    enable = true;
  };
}
