Git: Difference between revisions

m editing "settings.user" gets an error; intended property is "config.user"
DHCP (talk | contribs)
style fixes
Line 10: Line 10:


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
  environment.systemPackages = with pkgs; [  
environment.systemPackages = with pkgs; [  
    git  
  git  
  ];
];
</nowiki>}}
</nowiki>}}


Line 18: Line 18:


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
  programs.git.enable = true;
programs.git.enable = true;
</nowiki>}}
</nowiki>}}


Line 30: Line 30:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
  programs.git = {
programs.git = {
    enable = true;
  enable = true;
    config.user = {
  config.user = {
        name  = "John Doe";
    name  = "John Doe";
        email = "johndoe@example.com";
    email = "johndoe@example.com";
    };
   };
   };
};
</syntaxhighlight>
</syntaxhighlight>


Line 42: Line 42:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
  programs.git = {
programs.git = {
    enable = true;
  enable = true;
    settings.alias = {
  settings.alias = {
      ci = "commit";
    ci = "commit";
      co = "checkout";
    co = "checkout";
      s = "status";
    s = "status";
    };
   };
   };
};
</syntaxhighlight>
</syntaxhighlight>


Line 55: Line 55:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
  programs.git = {
programs.git = {
    enable = true;
  enable = true;
    lfs.enable = true;
  lfs.enable = true;
  };
};
</syntaxhighlight>
</syntaxhighlight>
Configure git-credential-helper with libsecret:
Configure git-credential-helper with libsecret:
Line 137: Line 137:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
  programs.git = {
programs.git = {
    enable = true;
  enable = true;
    package = pkgs.gitFull;
  package = pkgs.gitFull;
  };
};
</syntaxhighlight>
</syntaxhighlight>


Line 201: Line 201:
1. Run this on the server to create repo <code>myproject</code> accessible by user <code>git</code>
1. Run this on the server to create repo <code>myproject</code> accessible by user <code>git</code>


<syntaxhighlight lang="bash">
<syntaxhighlight lang="console">
sudo -u git bash -c "git init --bare ~/myproject.git"
$ sudo -u git bash -c "git init --bare ~/myproject.git"
</syntaxhighlight>
</syntaxhighlight>
(<code>~</code> here is the home of the user <code>git</code>, which is <code>/var/lib/git-server</code>)
(<code>~</code> here is the home of the user <code>git</code>, which is <code>/var/lib/git-server</code>)
Line 208: Line 208:
2. Push to the server repo from another system  
2. Push to the server repo from another system  


<syntaxhighlight lang="bash">
<syntaxhighlight lang="console">
mkdir myproject
$ mkdir myproject
cd myproject
$ cd myproject
echo hello > a
$ echo "hello" > a
git init
$ git init
git add .
$ git add .
git commit -m init
$ git commit -m "init"
git remote add origin git@myserver:myproject.git
$ git remote add origin git@myserver:myproject.git
git push origin master
$ git push origin master
</syntaxhighlight>
</syntaxhighlight>


3. Clone and edit the server repo from another system
3. Clone and edit the server repo from another system


<syntaxhighlight lang="bash">
<syntaxhighlight lang="console">
git clone git@myserver:myproject.git
$ git clone git@myserver:myproject.git
cd myproject
$ cd myproject
cat a
$ cat a
echo world >> a
$ echo "world" >> a
git commit -am hello
$ git commit -am "hello"
git push origin master
$ git push origin master
</syntaxhighlight>
</syntaxhighlight>