Git is a version control system. It is used for keeping track of changes made to source code, etc. The changes are often made by different people, though this is not necessary. Similar tools include CVS, Subversion, Mercurial, or Bazaar. Git is distributed source control management system, which means it does not require a central repository. Git can and often is used with a central repository workflow, though.
Git was originally developed by Linus Torvalds and friends for managing development of the Linux kernel. It is relatively new, though many large projects have adopted it.
This will install both a client and a server (disabled by default).
If you want to use gitk (visualisation tool), you should enable USE-Flag tk for dev-vcs/git.
- Watch the presentation by Randal Schwartz: .
- Git is documented through extensive man pages, which are replicated online. Go through the man pages: docs/.
- Go through the everyday Git docs: .
Setting up a network Server
This is how to set up a server which serves read-only content.
In order to set up a server, the default location for repositories is /var/git. Here is the simplest way to do it.
Server configuration file
Make your git-daemon configuration file (in /etc/conf.d) look like this:
What that does:
- Makes the "jail root" /var/git by specifying that at the end.
- Allows anything that looks like a repository to be exportable with the --export-all option. If you want more limitation, please remove this option and touch a file named git-daemon-export-ok
- Creates "virtual resources" of any repositories exported, by making the jail root prepended to all requests (git://server/blah looks for /var/git/blah).
- It should be noticed that all the repositories have write access to all the world. Use the --enable=receive-pack carefully only in trusted LAN
Check if the /var/git directory exists (otherwise git will not start). If not
Then start the daemon:
For some reason, it may take once or twice (it will error with !! instead of OK).
Setting up repositories
First, the daemon will be run as nobody, so become nobody:
And execute all further commands in that shell.
First, create a project directory inside of the daemon's root directory (thought of as a jail root):
Next, put all the files in there. This is the directory which will be cloned ("checked out" in more centralized terminology).
Finally, make it into a GIT repository:
If you have multiple projects, create one directory for each according to the above steps.
If clients wish to check out the project, tell them to run:
Multi User Git Server
When pushing into Git server using ssh, the ownership of the new files are associated with the user who performs the push. This does not allow other users to use the same repository. One solution is to change the default umask of a user, however, this will effect more than the Git operations.
A proper solution can be established using POSIX access control lists.
Enable ACLs in kernel, for example for ext4 filesystem, use:
|Linux Kernel Configuration:|
File systems ---> <*> The Extended 4 (ext4) filesystem [*] Ext4 extended attributes [*] Ext4 POSIX Access Control Lists
Add "acl" to mount options:
Create gitusers group:
For each Git repository REPOS:
The above will set default read and write access to gitusers groups for every file created within repository.
Now members of gitusers group can push/pull repository.