At the time of this writing, Git is (seemingly) not installed by default on any GNU/Linux distribution or any other operating system. So, before you can use Git, you must install it. The steps to install Git depend greatly on the vendor and version of your operating system. This chapter describes how to install Git on Linux and Microsoft Windows and within Cygwin.
Many Linux vendors provide pre-compiled, binary packages to make installation of new applications, tools, and utilities easy. Each package specifies its dependencies, and the distribution’s package manager typically installs the prerequisites and the desired package in one (well-orchestrated and automated) fell swoop.
On most Debian and Ubuntu systems, Git is offered as a collection of packages, where each package can be installed independently depending on your needs. The primary Git package is called git-core, documentation is available in git-doc, and there are other packages to consider, too:
If you need to transfer a project from Arch, CVS, or Subversion to Git or vice versa, install one or more of these packages.
If you prefer to browse repositories in a graphical application or your Web browser, install these as appropriate. git-gui is a Tcl/Tk-based graphical user interface for Git; gitk is another Git browser written in Tcl/Tk but focuses more on visualizing project history. gitweb is written in Perl and displays a Git repository in a browser window.
This is an essential component if you want to send Git patches through electronic mail, which is a common practice in some projects.
To share your repository, install this package. It creates a daemon service that allows you to share your repositories through anonymous download requests.
Because distributions vary greatly, it’s best to search your distribution’s package depot for a complete list of Git-related packages. git-doc and git-email are strongly recommended.
Debian and Ubuntu provide a package named git, but it isn’t a part of the Git version control system discussed in this book. git is a completely different program called GNU Interactive Tools. Be careful not to install the wrong package by accident!
This command installs the important Git packages by running apt-get as the root:
$sudo apt-get install git-core git-doc gitweb
git-gui gitk git-email git-svn
To install Git on other Linux distributions, find the appropriate package or packages and use the distribution’s native package manager to install the software.
For example, on Gentoo systems, use emerge:
$ sudo emerge dev-util/git
$ sudo yum install git
The Fedora git is roughly equivalent to
Debian’s git-core. Other i386
Fedora packages include:
The core git tools
A metapackage for pulling in all Git tools
Git tools for importing Arch repositories
Git tools for importing CVS repositories
The Git protocol daemon
Debug information for package Git
Git tools for sending email
Git GUI tool
Git tools for importing Subversion repositories
Git revision tree visualizer
Again, be mindful that, like Debian, some distributions may split the Git release among many different packages. If your system lacks a particular Git command, you may need to install an additional package.
Be sure to verify that your distribution’s Git packages are sufficiently up-to-date. After Git is installed on your system, run git --version. If your collaborators use a more modern version of Git, you may have to replace your distribution’s precompiled Git packages with a build of your own. Consult your package manager documentation to learn how to remove previously installed packages; proceed to the next section to learn how to build Git from source.
52.15.147.20