Git: Difference between revisions

From NixOS Wiki
imported>Profpatsch
nixpkgs management git-gc section
imported>Ikovnatsky
Add git-credential-helper with libsecret
Line 23: Line 23:
     userEmail = "johndoe@example.com";
     userEmail = "johndoe@example.com";
   };
   };
</syntaxhighlight>
Configure git-credential-helper with libsecret:
<syntaxhighlight lang="nix">
{ pkgs, ... }:
{
  programs.git = {
    enable = true;
    extraConfig = {
      credential.helper = "${
          pkgs.git.override { withLibsecret = true; }
        }/bin/git-credential-libsecret";
    };
  };
}
</syntaxhighlight>
</syntaxhighlight>



Revision as of 12:17, 30 March 2021

Git is the version control system (VCS) designed and developed by Linus Torvalds, the creator of the Linux kernel. Git is used to maintain NixOS packages, as well as many other projects, including sources for the Linux kernel.

Installation

Install the git package.

Additional features

Install tk to use the git gui:

git citool

Configuration

Git can be configured using Home Manager:

  programs.git = {
    enable = true;
    userName  = "John Doe";
    userEmail = "johndoe@example.com";
  };

Configure git-credential-helper with libsecret:

{ pkgs, ... }:

{
  programs.git = {
    enable = true;
    extraConfig = {
      credential.helper = "${
          pkgs.git.override { withLibsecret = true; }
        }/bin/git-credential-libsecret";
    };
  };
}

Management of the nixpkgs git repository

nixpkgs has become a git repository of quite substantial size with > 160 000 commits (as of early 2019). This brings many unoptimized tools to their limits, leading to long waiting times on certain operations. Here we’ll collect useful info on how to manage that.

git

git itself might not perform as usual with the default settings

git-gc

Normal git gc should work as usual, but you should force a full garbage collect every half a year or so. git gc --aggressive is the command for that. For the author it did not work on the first try, since their laptop’s memory was too small and it went out of memory. According to StackOverflow answer it suffices to set some local repository config variables.

git config pack.windowMemory 2g
git config pack.packSizeLimit 1g

worked well on a machine with about 6–8 GB of free RAM and two processor threads, and reduced the size of the nixpkgs checkout from ~1.3 GB to ~0.95 GB.