Git
From Gentoo Linux Wiki
Contents |
[edit] Introduction
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.
[edit] Installation
This will install both a client and a server (disabled by default).
[edit] Setting up a Server
While git is designed to have a distributed model in mind, it is still often used in a client-server form. This is how to set up a server which serves content. Note that updating it is done by hand (pushes are not permitted through the daemon); this is setting up anonymous, automatic cloning.
In order to set up a server, the default location for repositories is /var/git. Here is the simplest way to do it.
[edit] Server configuration file
Make your git-daemon configuration file (in /etc/conf.d) look like this:
# conf.d file for git-daemon # # Please check man 1 git-daemon for more information about the options # git-daemon accepts. You MUST edit this to include your repositories you wish # to serve. # # Some of the meaningful options are: # --syslog --- Enables syslog logging # --verbose --- Enables verbose logging # --export-all --- Exports all repositories # --port=XXXX --- Starts in port XXXX instead of 9418 # GITDAEMON_OPTS="--syslog --enable=receive-pack --export-all --base-path=/var/git /var/git" # To run an anonymous git safely, the following user should be able to only # read your Git repositories. It should not able able to write to anywhere on # your system, esp. not the repositories. GIT_USER="nobody" GIT_GROUP="nobody"
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.
- Creates "virtual resources" of any repositories exported, by making the jail root prepended to all requests (git://server/blah looks for /var/git/blah).
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).
[edit] 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:
[edit] Client Usage
- Watch the presentation by Randal Schwartz: [1].
- Git is documented through extensive man pages, which are replicated online. Go through the man pages: docs/.
- Go through the everyday Git docs: [2].
