Git: Difference between revisions

imported>Erikarvstedt
mNo edit summary
Qweered (talk | contribs)
m cleaner
 
(10 intermediate revisions by 6 users not shown)
Line 16: Line 16:


== Configuration ==
== Configuration ==
Git can be configured using [[Home Manager]]:
Git can be configured using [[Home Manager]]:


Line 56: Line 55:
   programs.git = {
   programs.git = {
     enable = true;
     enable = true;
    package = pkgs.git.override { withLibsecret = true; };
     extraConfig = {
     extraConfig = {
       credential.helper = "${
       credential.helper = "libsecret";
          pkgs.git.override { withLibsecret = true; }
        }/bin/git-credential-libsecret";
     };
     };
   };
   };
Line 83: Line 81:
       push = { autoSetupRemote = true; };
       push = { autoSetupRemote = true; };
     };
     };
  };
}
</syntaxhighlight>
=== Using your public SSH key as a signing key ===
You can naturally configure git to automatically sign your commits using your public SSH key like so:<syntaxhighlight lang="nix">
{
  programs.git = {
    enable = true;
    signing = {
      key = "ssh-ed25519 AAAAAAAAAAAA...AA username@hostname";
      signByDefault = true;
    };
    extraConfig = {
      gpg = {
        format = "ssh";
      };
    };
  };
}
</syntaxhighlight>However, note that this will also require Home Manager to manage your SSH configuration:<syntaxhighlight lang="nix">
{   
  programs.ssh = {
    enable = true;
    addKeysToAgent = "yes";
   };
   };
}
}
Line 109: Line 132:


This section implements [https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server Git on the Server - Setting Up the Server] on NixOS.
This section implements [https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server Git on the Server - Setting Up the Server] on NixOS.
See also: [[gitolite]].


== Configuration ==
== Configuration ==
Line 147: Line 172:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo -u git bash -c '
sudo -u git bash -c "git init --bare ~/myproject.git"
  cd /var/lib/git-server
  mkdir myproject.git
  cd myproject.git
  git init --bare
'
</syntaxhighlight>
</syntaxhighlight>
(<code>~</code> here is the home of the user <code>git</code>, which is <code>/var/lib/git-server</code>)


2. Push to the server repo from another system  
2. Push to the server repo from another system  


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mkdir myproject1
mkdir myproject
cd myproject1
cd myproject
echo hello > a
echo hello > a
git init
git init
Line 178: Line 199:
git push origin master
git push origin master
</syntaxhighlight>
</syntaxhighlight>
== Bisecting Nix regressions ==
see [[bisecting]]


[[Category:Applications]]
[[Category:Applications]]
[[Category:CLI Applications]]
[[Category:Version control]]