Git: Difference between revisions
RyoKimball (talk | contribs) m editing "settings.user" gets an error; intended property is "config.user" |
style fixes |
||
| Line 10: | Line 10: | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
environment.systemPackages = with pkgs; [ | |||
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; | |||
</nowiki>}} | </nowiki>}} | ||
| Line 30: | Line 30: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
programs.git = { | |||
enable = true; | |||
config.user = { | |||
name = "John Doe"; | |||
email = "johndoe@example.com"; | |||
}; | }; | ||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 42: | Line 42: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
programs.git = { | |||
enable = true; | |||
settings.alias = { | |||
ci = "commit"; | |||
co = "checkout"; | |||
s = "status"; | |||
}; | }; | ||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 55: | Line 55: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
programs.git = { | |||
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 = { | |||
enable = true; | |||
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=" | <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=" | <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=" | <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> | ||