Skip to content
28 changes: 17 additions & 11 deletions book/01-introduction/1-introduction.asc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ This chapter will be about getting started with Git.
We will begin at the beginning by explaining some background on version control tools, then move on to how to get Git running on your system and finally how to get it setup to start working with.
At the end of this chapter you should understand why Git is around, why you should use it and you should be all setup to do so.

=== About Version Control (((version control)))
=== About Version Control

(((version control)))
What is "version control", and why should you care?
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
For the examples in this book you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.
Expand All @@ -16,8 +17,9 @@ It allows you to revert files back to a previous state, revert the entire projec
Using a VCS also generally means that if you screw things up or lose files, you can easily recover.
In addition, you get all this for very little overhead.

==== Local Version Control Systems (((version control,local version control)))
==== Local Version Control Systems

(((version control,local)))
Many people’s version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they’re clever).
This approach is very common because it is so simple, but it is also incredibly error prone.
It is easy to forget which directory you’re in and accidentally write to the wrong file or copy over files you don’t mean to.
Expand All @@ -31,8 +33,9 @@ One of the more popular VCS tools was a system called RCS, which is still distri
Even the popular Mac OS X operating system includes the `rcs` command when you install the Developer Tools.
RCS works by keeping patch sets (that is, the differences between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches.

==== Centralized Version Control Systems (((version control,centralized version control)))
==== Centralized Version Control Systems

(((version control,centralized)))
The next major issue that people encounter is that they need to collaborate with developers on other systems.
To deal with this problem, Centralized Version Control Systems (CVCSs) were developed.
These systems, such as CVS, Subversion, and Perforce, have a single server that contains all the versioned files, and a number of clients that check out files from that central place. (((CVS)))(((Subversion)))(((Perforce)))
Expand All @@ -51,8 +54,9 @@ If that server goes down for an hour, then during that hour nobody can collabora
If the hard disk the central database is on becomes corrupted, and proper backups haven’t been kept, you lose absolutely everything – the entire history of the project except whatever single snapshots people happen to have on their local machines.
Local VCS systems suffer from this same problem – whenever you have the entire history of the project in a single place, you risk losing everything.

==== Distributed Version Control Systems (((version control,distributed version control)))
==== Distributed Version Control Systems

(((version control,distributed)))
This is where Distributed Version Control Systems (DVCSs) step in.
In a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients don’t just check out the latest snapshot of the files: they fully mirror the repository.
Thus if any server dies, and these systems were collaborating via it, any of the client repositories can be copied back up to the server to restore it.
Expand Down Expand Up @@ -80,7 +84,7 @@ Some of the goals of the new system were as follows:
* Simple design
* Strong support for non-linear development (thousands of parallel branches)
* Fully distributed
* Able to handle large projects like the Linux kernel efficiently (speed and data size)(((Linux)))
* Able to handle large projects like the Linux kernel efficiently (speed and data size)

Since its birth in 2005, Git has evolved and matured to be easy to use and yet retain these initial qualities.
It’s incredibly fast, it’s very efficient with large projects, and it has an incredible branching system for non-linear development (See <<_git_branching>>).
Expand Down Expand Up @@ -209,8 +213,9 @@ Before you start using Git, you have to make it available on your computer.
Even if it's already installed, it's probably a good idea to update to the latest version.
You can either install it as a package or via another installer, or download the source code and compile it yourself.

==== Installing on Linux(((Linux, installing)))
==== Installing on Linux

(((Linux, installing)))
If you want to install Git on Linux via a binary installer, you can generally do so through the basic package-management tool that comes with your distribution.
If you’re on Fedora for example, you can use yum:

Expand All @@ -222,8 +227,9 @@ If you’re on a Debian-based distribution like Ubuntu, try apt-get:

For more options, there are instructions for installing on several different Unix flavors on the Git website, at http://git-scm.com/download/linux[].

==== Installing on Mac(((Mac, installing)))
==== Installing on Mac

(((Mac, installing)))
There are several ways to install Git on a Mac.
The easiest is probably to install the Xcode Command Line Tools.(((Xcode)))
On Mavericks (10.9) or above you can do this simply by trying to run 'git' from the Terminal the very first time.
Expand All @@ -248,7 +254,7 @@ Note that this is a project called Git for Windows (also called msysGit), which

Another easy way to get Git installed is by installing GitHub for Windows.
The installer includes a command line version of Git as well as the GUI.
It also works well with Powershell, and sets up solid credential caching and sane CRLF settings.
It also works well with Powershell, and sets up solid credential caching and sane CRLF settings.((Powershell))((CRLF))((credential caching))
We'll learn more about those things a little later, but suffice it to say they're things you want.

==== Installing from Source
Expand Down Expand Up @@ -289,7 +295,7 @@ Now that you have Git on your system, you’ll want to do a few things to custom
You should have to do these things only once on any given computer; they’ll stick around between upgrades.
You can also change them at any time by running through the commands again.

Git comes with a tool called `git config` that lets you get and set configuration variables that control all aspects of how Git looks and operates.(((git, config)))
Git comes with a tool called `git config` that lets you get and set configuration variables that control all aspects of how Git looks and operates.(((git commands, config)))
These variables can be stored in three different places:

1. `/etc/gitconfig` file: Contains values for every user on the system and all their repositories.
Expand Down Expand Up @@ -345,7 +351,7 @@ If you want to check your settings, you can use the `git config --list` command
You may see keys more than once, because Git reads the same key from different files (`/etc/gitconfig` and `~/.gitconfig`, for example).
In this case, Git uses the last value for each unique key it sees.

You can also check what Git thinks a specific key’s value is by typing `git config <key>`:(((git, config)))
You can also check what Git thinks a specific key’s value is by typing `git config <key>`:(((git commands, config)))

$ git config user.name
John Doe
Expand All @@ -358,7 +364,7 @@ If you ever need help while using Git, there are three ways to get the manual pa
$ git <verb> --help
$ man git-<verb>

For example, you can get the manpage help for the config command by running(((git, help)))
For example, you can get the manpage help for the config command by running(((git commands, help)))

$ git help config

Expand Down
Loading