Git

Git is Article description::distributed revision control and source code management software. The goal of this article is to easily get a Git repository up and running.

Git was developed by Linus Torvalds for use on the Linux Kernel and other open source projects. According to a talk he gave for Google, he was searching for a Source Control Management (SCM) and used three criteria.

SCM must:


 * 1) Be distributed;
 * 2) Be fast;
 * 3) Output exactly what was put in, or an error should be printed.

Since there were no satisfactory options Linus wrote.

Emerge
Install :

Additional software
There are a number of additional applications that are associated with git and are of note:

This is a partial selection of packages available in the Gentoo repository, see p.g.o/categories/dev-vcs, or use eix, to see packages from the dev-vcs category that may be of interest.

There is additional software in the GURU repository, such as the gitui and lazygit guis.

Configuration
Before contributing to a project it is imperative to establish a user name and email for each user. Substitute the bracketed Larry references (brackets and everything in-between, but leave the quotes) in the next example for a personal user name and e-mail address:

Local
If you're the only one using your project, or if you're creating something which will be shared in a distributed way, then you should start on your workstation. If you intend to have a central server which everyone uses as the "official" server (e.g. GitHub) then it might be easier to create an empty repository there.

The next list of commands will describe how to create a repository on a workstation:

You're done. You've created a local repository. It's in the folder, so don't delete your  folder unless you mean to lose everything.

Now, let's say we make some edits:

The new file must be added (staged) before it can be included in the git repository. Use the next commands to stage the file and to make the commit:

Server
In this section will cover setting up a Git server for remote project management through SSH.

If not sure then skip this section.

Initial setup
Start by creating the needed group, user, and home directory. The user uses the  to prevent normal shell access.

Edit to change user from "nobody" to "git" and start the daemon:

If wants to accept git push and allow access all direct, it needs to add two options --enable=receive-pack and --export-all to GITDAEMON_OPTS, ex:

SSH keys
SSH is the preferred method to handle the secure communications between client and server. For Git to work properly, you must have private/public key logins enabled and all client public keys added to.

For more information and instructions on how to enable, create, and share keys, please see the SSH - Passwordless Authentication wiki page.

Create a repository and make the initial commit
On the server:

Become the git user to make sure all objects are owned by this user:

Create a bare repository:

On a the client station:

Common commands
Clone a repository:

Repository management via GUI
Git ships with a tk GUI. Invoke it using:

Serving and managing repositories via builtin web interface
Git comes with a built-in web interface called. It can run on a variety of web servers:


 * lighttpd - No configuration necessary.
 * Apache - Some configuration necessary.
 * nginx - A small, robust, and high-performance HTTP server and reverse proxy.

In order to use be sure one of the three web servers has been installed and  has been built with the   USE flag.

There is a simple setup script that will create a working default configuration, start a web server (the default configuration is for ) and open the URL in a browser. Navigate to the repositories directory. Once inside type:

If opens a 404 error, enable the   USE flag and rebuild.

Help
Find out more about the options using the the built-in help output:

For additional help consider reading the contextual man page:

Configuration
Per-project configuration can be set in the repositories file:

Values in this file should be specific in an ini-style format:

Adjust the values as needed. If the  light is uncommented (remove the  )  will only be connectable from the localhost.

External resources

 * https://www.codeschool.com/courses/git-real - Free, good, basic first-time tutorial
 * git flow documentation - Client side scripts to make git repository management a snap.
 * The Official Git Handbook - Hosted at the official git website.
 * Git - The simple guide
 * Git from the inside out - A well written publication from the Recurse Center. This article addresses what happens beneath the surface when using git.
 * Lesser known git commands - A blog entry on helpful commands that go unnoticed.