Skip to content

Commit 9f01aeb

Browse files
committed
Polish for chapter 1
1 parent 1c0df74 commit 9f01aeb

File tree

3 files changed

+53
-70
lines changed

3 files changed

+53
-70
lines changed

en/book/01-introduction/chapter1.asc

Lines changed: 53 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,22 @@ Many people’s version-control method of choice is to copy files into another d
2121
This approach is very common because it is so simple, but it is also incredibly error prone.
2222
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.
2323

24-
To deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control (see <<local_version_control>>).
24+
To deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control.
2525

26-
[[local_version_control]]
2726
.Local version control.
2827
image::images/18333fig0101-tn.png[Local version control diagram]
2928

30-
One of the more popular VCS tools was a system called rcs, which is still distributed with many computers today.
31-
Even the popular Mac OS X operating system includes the rcs command when you install the Developer Tools.
32-
This tool basically works by keeping patch sets (that is, the differences between files) from one change to another 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.
29+
One of the more popular VCS tools was a system called RCS, which is still distributed with many computers today.
30+
Even the popular Mac OS X operating system includes the `rcs` command when you install the Developer Tools.
31+
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.
3332

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

3635
The next major issue that people encounter is that they need to collaborate with developers on other systems.
3736
To deal with this problem, Centralized Version Control Systems (CVCSs) were developed.
3837
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.
39-
For many years, this has been the standard for version control (see <<central_version_control>>).
38+
For many years, this has been the standard for version control.
4039

41-
[[central_version_control]]
4240
.Centralized version control.
4341
image::images/18333fig0102-tn.png[Centralized version control diagram]
4442

@@ -49,17 +47,16 @@ Administrators have fine-grained control over who can do what; and it’s far ea
4947
However, this setup also has some serious downsides.
5048
The most obvious is the single point of failure that the centralized server represents.
5149
If that server goes down for an hour, then during that hour nobody can collaborate at all or save versioned changes to anything they’re working on.
52-
If the hard disk the central database is on becomes corrupted, and proper backups haven’t been kept, you lose absolutely everythingthe entire history of the project except whatever single snapshots people happen to have on their local machines.
53-
Local VCS systems suffer from this same problemwhenever you have the entire history of the project in a single place, you risk losing everything.
50+
If the hard disk the central database is on becomes corrupted, and proper backups haven’t been kept, you lose absolutely everythingthe entire history of the project except whatever single snapshots people happen to have on their local machines.
51+
Local VCS systems suffer from this same problemwhenever you have the entire history of the project in a single place, you risk losing everything.
5452

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

5755
This is where Distributed Version Control Systems (DVCSs) step in.
5856
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.
5957
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.
60-
Every checkout is really a full backup of all the data (see <<dist_version_control>>).
58+
Every checkout is really a full backup of all the data.
6159

62-
[[dist_version_control]]
6360
.Distributed version control.
6461
image::images/18333fig0103-tn.png[Distributed version control diagram]
6562

@@ -69,9 +66,10 @@ This allows you to set up several types of workflows that aren’t possible in c
6966
=== A Short History of Git
7067

7168
As with many great things in life, Git began with a bit of creative destruction and fiery controversy.
69+
7270
The Linux kernel is an open source software project of fairly large scope.
7371
For most of the lifetime of the Linux kernel maintenance (1991–2002), changes to the software were passed around as patches and archived files.
74-
In 2002, the Linux kernel project began using a proprietary DVCS system called BitKeeper.
72+
In 2002, the Linux kernel project began using a proprietary DVCS called BitKeeper.
7573

7674
In 2005, the relationship between the community that developed the Linux kernel and the commercial company that developed BitKeeper broke down, and the tool’s free-of-charge status was revoked.
7775
This prompted the Linux development community (and in particular Linus Torvalds, the creator of Linux) to develop their own tool based on some of the lessons they learned while using BitKeeper.
@@ -91,26 +89,24 @@ It’s incredibly fast, it’s very efficient with large projects, and it has an
9189
So, what is Git in a nutshell?
9290
This is an important section to absorb, because if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you.
9391
As you learn Git, try to clear your mind of the things you may know about other VCSs, such as Subversion and Perforce; doing so will help you avoid subtle confusion when using the tool.
94-
Git stores and thinks about information much differently than these other systems, even though the user interface is fairly similar; understanding those differences will help prevent you from becoming confused while using it.
92+
Git stores and thinks about information much differently than these other systems, even though the user interface is fairly similar, and understanding those differences will help prevent you from becoming confused while using it.
9593

9694
==== Snapshots, Not Differences
9795

9896
The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data.
9997
Conceptually, most other systems store information as a list of file-based changes.
100-
These systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the information they keep as a set of files and the changes made to each file over time, as illustrated in <<stream_of_deltas>>.
98+
These systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the information they keep as a set of files and the changes made to each file over time.
10199

102-
[[stream_of_deltas]]
103-
.Other systems tend to store data as changes to a base version of each file.
104-
image::images/18333fig0104-tn.png[Other systems tend to store data as changes to a base version of each file.]
100+
.Storing data as changes to a base version of each file.
101+
image::images/18333fig0104-tn.png[Storing data as changes to a base version of each file.]
105102

106103
Git doesn’t think of or store its data this way.
107-
Instead, Git thinks of its data more like a set of snapshots of a mini filesystem.
104+
Instead, Git thinks of its data more like a set of snapshots of a miniature filesystem.
108105
Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.
109-
To be efficient, if files have not changed, Git doesn’t store the file againjust a link to the previous identical file it has already stored.
110-
Git thinks about its data more like <<stream_of_snapshots>>.
106+
To be efficient, if files have not changed, Git doesn’t store the file again, just a link to the previous identical file it has already stored.
107+
Git thinks about its data more like a *stream of snapshots*.
111108

112-
[[stream_of_snapshots]]
113-
.Git stores data as snapshots of the project over time.
109+
.Storing data as snapshots of the project over time.
114110
image::images/18333fig0105-tn.png[Git stores data as snapshots of the project over time.]
115111

116112
This is an important distinction between Git and nearly all other VCSs.
@@ -124,7 +120,7 @@ Most operations in Git only need local files and resources to operate – genera
124120
If you’re used to a CVCS where most operations have that network latency overhead, this aspect of Git will make you think that the gods of speed have blessed Git with unworldly powers.
125121
Because you have the entire history of the project right there on your local disk, most operations seem almost instantaneous.
126122

127-
For example, to browse the history of the project, Git doesn’t need to go out to the server to get the history and display it for youit simply reads it directly from your local database.
123+
For example, to browse the history of the project, Git doesn’t need to go out to the server to get the history and display it for youit simply reads it directly from your local database.
128124
This means you see the project history almost instantly.
129125
If you want to see the changes introduced between the current version of a file and the file a month ago, Git can look up the file a month ago and do a local difference calculation, instead of having to either ask a remote server to do it or pull an older version of the file from the remote server to do it locally.
130126

@@ -180,7 +176,7 @@ This is the most important part of Git, and it is what is copied when you clone
180176
The working directory is a single checkout of one version of the project.
181177
These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.
182178

183-
The staging area is a simple file, generally contained in your Git directory, that stores information about what will go into your next commit.
179+
The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit.
184180
It’s sometimes referred to as the index, but it’s also common to refer to it as the staging area.
185181

186182
The basic Git workflow goes something like this:
@@ -196,19 +192,19 @@ In <<_git_basics_chapter>>, you’ll learn more about these states and how you c
196192

197193
=== The Command Line
198194

199-
There are a lot of different ways to use Git these days.
200-
There are the original command line tools and there are many graphical user interfaces as well of varying capabilities.
195+
There are a lot of different ways to use Git.
196+
There are the original command line tools, and there are many graphical user interfaces of varying capabilities.
201197
For this book, we will be using Git on the command line.
202-
For one, the command line is the only place you can run *all* Git commands - most of the GUIs only implement some subset of Git functionality for simplicity.
198+
For one, the command line is the only place you can run *all* Git commands most of the GUIs only implement some subset of Git functionality for simplicity.
203199
If you know how to run the command line version, you can probably also figure out how to run the GUI version, while the opposite is not neccesarily true.
204-
Finally, while your choice of graphical client is a matter of personal taste, _all_ users will have the command-line tools installed and available.
200+
Also, while your choice of graphical client is a matter of personal taste, _all_ users will have the command-line tools installed and available.
205201

206-
So, we will expect you to know how to open Terminal in Mac or Command Prompt or Powershell in Windows.
202+
So we will expect you to know how to open Terminal in Mac or Command Prompt or Powershell in Windows.
207203
If you don't know what we're talking about here, you may need to stop and research that quickly so that you can follow the rest of the examples and descriptions in this book.
208204

209205
=== Installing Git
210206

211-
Let’s get into using some Git.
207+
Before you start using Git, you have to make it available on your computer.
212208
Even if it's already installed, it's probably a good idea to update to the latest version.
213209
You can either install it as a package or via another installer, or download the source code and compile it yourself.
214210

@@ -223,9 +219,7 @@ Or if you’re on a Debian-based distribution like Ubuntu, try apt-get:
223219

224220
$ apt-get install git
225221

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

230224
==== Installing on Mac
231225

@@ -235,50 +229,44 @@ On Mavericks (10.9) or above you can do this simply by trying to run 'git' from
235229
If you don't have it installed already, it will prompt you to install it.
236230

237231
If you want a more up to date version, you can also install it via a binary installer.
238-
An OSX Git installer is maintained and available for download here:
239-
240-
http://sourceforge.net/projects/git-osx-installer/
232+
An OSX Git installer is maintained and available for download at the Git website, at http://git-scm.com/download/mac[].
241233

242-
[[git_osx_installer]]
243234
.Git OS X Installer.
244-
image::images/18333fig0107-tn.png[Git OS X installer.]
235+
image::images/git-osx-installer.png[Git OS X installer.]
245236

246237
You can also install it as part of the GitHub for Mac install.
247238
Their GUI Git tool has an option to install command line tools as well.
248-
You can download that tool from the GitHub for Mac website.
249-
250-
http://mac.github.com/
239+
You can download that tool from the GitHub for Mac website, at http://mac.github.com[].
251240

252241
==== Installing on Windows
253242

254243
There are also a few ways to install Git on Windows.
255-
You can go to the Git website to have it automatically download the current MsysGit installer.
256-
257-
http://git-scm.com/download/win
258-
259-
If you want more information on the MsysGit project or build, you can also go directly to their homepage.
244+
The most official build is available for download on the Git website.
245+
Just go to http://git-scm.com/download/win[] and the download will start automatically.
246+
Note that this is a project called Git for Windows (also called msysGit), which is separate from Git itself; for more information on it, go to http://msysgit.github.io/[].
260247

261-
http://msysgit.github.io
262248

263-
The GitHub for Windows installer will also install a command line version of Git as well as the GUI, so that is another easy option.
264-
It also works well with Powershell and sets up solid credential caching options and sane CRLF settings, so many people find it a simpler installation option.
265-
We'll learn more about both of those things a little later.
249+
Another easy way to get Git installed is by installing GitHub for Windows.
250+
The installer includes a command line version of Git as well as the GUI.
251+
It also works well with Powershell, and sets up solid credential caching and sane CRLF settings.
252+
We'll learn more about those things a little later, but suffice it to say they're things you want.
266253

267254
=== First-Time Git Setup
268255

269256
Now that you have Git on your system, you’ll want to do a few things to customize your Git environment.
270-
You should have to do these things only once; they’ll stick around between upgrades.
257+
You should have to do these things only once on any given computer; they’ll stick around between upgrades.
271258
You can also change them at any time by running through the commands again.
272259

273260
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.
274261
These variables can be stored in three different places:
275262

276-
* `/etc/gitconfig` file: Contains values for every user on the system and all their repositories.
263+
1. `/etc/gitconfig` file: Contains values for every user on the system and all their repositories.
277264
If you pass the option` --system` to `git config`, it reads and writes from this file specifically.
278-
* `~/.gitconfig` file: Specific to your user.
265+
2. `~/.gitconfig` or `~/.config/git/config` file: Specific to your user.
279266
You can make Git read and write to this file specifically by passing the `--global` option.
280-
* `config` file in the Git directory (that is, `.git/config`) of whatever repository you’re currently using: Specific to that single repository.
281-
Each level overrides values in the previous level, so values in `.git/config` trump those in `/etc/gitconfig`.
267+
3. `config` file in the Git directory (that is, `.git/config`) of whatever repository you’re currently using: Specific to that single repository.
268+
269+
Each level overrides values in the previous level, so values in `.git/config` trump those in `/etc/gitconfig`.
282270

283271
On Windows systems, Git looks for the `.gitconfig` file in the `$HOME` directory (`C:\Users\$USER` for most people).
284272
It also still looks for `/etc/gitconfig`, although it’s relative to the MSys root, which is wherever you decide to install Git on your Windows system when you run the installer.
@@ -298,22 +286,17 @@ For example, if you’re on a system that has yum (such as Fedora) or apt-get (s
298286
libz-dev libssl-dev
299287

300288
When you have all the necessary dependencies, you can go ahead and grab the latest tagged release tarball from several places.
301-
You can get it via the Kernel.org site.
302-
303-
https://www.kernel.org/pub/software/scm/git
304-
305-
Or the mirror on the GitHub web site.
306-
307-
https://github.com/git/git/releases
308-
289+
You can get it via the Kernel.org site, at https://www.kernel.org/pub/software/scm/git[], or the mirror on the GitHub web site, at https://github.com/git/git/releases[].
309290
It's generally a little clearer what the latest version is on the GitHub page, but the kernel.org page also has release signatures if you want to verify your download.
310291

311292
Then, compile and install:
312293

313294
$ tar -zxf git-1.9.1.tar.gz
314295
$ cd git-1.9.1
315-
$ make prefix=/usr all doc info
316-
$ sudo make prefix=/usr install install-doc install-html install-info
296+
$ make configure
297+
$ ./configure --prefix=/usr
298+
$ make all doc info
299+
$ sudo make install install-doc install-html install-info
317300

318301
After this is done, you can also get Git via Git itself for updates:
319302

@@ -335,7 +318,7 @@ Many of the GUI tools will help you do this when you first run them as well.
335318
==== Your Editor
336319

337320
Now that your identity is set up, you can configure the default text editor that will be used when Git needs you to type in a message.
338-
By default, Git uses your system’s default editor, which is generally Vi or Vim.
321+
By default, Git uses your system’s default editor, which is generally vi or Vim.
339322
If you want to use a different text editor, such as Emacs, you can do the following:
340323

341324
$ git config --global core.editor emacs
@@ -345,8 +328,8 @@ If you want to use a different text editor, such as Emacs, you can do the follow
345328
If you want to check your settings, you can use the `git config --list` command to list all the settings Git can find at that point:
346329

347330
$ git config --list
348-
user.name=Scott Chacon
349-
user.email=schacon@gmail.com
331+
user.name=John Doe
332+
user.email=johndoe@example.com
350333
color.status=auto
351334
color.branch=auto
352335
color.interactive=auto
@@ -356,10 +339,10 @@ If you want to check your settings, you can use the `git config --list` command
356339
You may see keys more than once, because Git reads the same key from different files (`/etc/gitconfig` and `~/.gitconfig`, for example).
357340
In this case, Git uses the last value for each unique key it sees.
358341

359-
You can also check what Git thinks a specific key’s value is by typing `git config {key}`:
342+
You can also check what Git thinks a specific key’s value is by typing `git config <key>`:
360343

361344
$ git config user.name
362-
Scott Chacon
345+
John Doe
363346

364347
=== Getting Help
365348

en/book/images/18333fig0107-tn.png

-67.6 KB
Binary file not shown.
332 KB
Loading

0 commit comments

Comments
 (0)