Skip to content

Commit 839f7e0

Browse files
committed
Minor edits.
1 parent f392970 commit 839f7e0

8 files changed

+109
-83
lines changed

book.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ pre {
1313
}
1414

1515
ul li p {
16-
margin-bottom:0;
16+
margin: 0;
17+
padding: 0;
1718
}
1819

1920
/* Based on http://phrogz.net/CSS/columns3.html */

en/basic.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To save the state again:
2323

2424
=== Add, Delete, Rename ===
2525

26-
The above will only keep track of the files that were present when you first ran *git add*. If you add new files or subdirectories, you'll have to tell Git:
26+
The above only keeps track of the files that were present when you first ran *git add*. If you add new files or subdirectories, you'll have to tell Git:
2727

2828
$ git add readme.txt Documentation
2929

@@ -164,7 +164,7 @@ and your users can upgrade their version by changing to the directory containing
164164

165165
$ git pull
166166

167-
Your users will never end up with a version of your script you don't want them to see. Obviously this trick works for anything, not just scripts.
167+
Your users will never end up with a version of your script you don't want them to see.
168168

169169
=== What Have I Done? ===
170170

@@ -193,7 +193,7 @@ fire up any web browser.
193193

194194
=== Exercise ===
195195

196-
Let A, B, C, D be four successive commits where B is the same as A except some files have been removed. We want to add the files back at D and not at B. How can we do this?
196+
Let A, B, C, D be four successive commits where B is the same as A except some files have been removed. We want to add the files back at D. How can we do this?
197197

198198
There are at least three solutions. Assuming we are at D:
199199

en/branch.txt

+15-15
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Then once you've fixed the bug:
8282

8383
and resume work on your original task.
8484

85-
You can even merge in the bugfix you just made, either by typing:
85+
You can even 'merge' in the bugfix you just made, either by typing:
8686

8787
$ git merge fixes
8888

@@ -94,38 +94,38 @@ since you have already pushed the bugfix to the main repository.
9494

9595
=== Merging ===
9696

97-
With many version control systems, creating branches is easy but merging them
97+
With some version control systems, creating branches is easy but merging them
9898
back together is tough. With Git, merging is so trivial that you might be
9999
unaware of it happening.
100100

101101
Indeed, though we have just introduced *git merge*, we encountered merging long ago. The *pull* command in fact fetches commits and then merges them into your current branch. If you have no local changes, then the merge is a 'fast forward', a degenerate case akin to fetching the latest version in a centralized version control system. But if you do have local changes, Git will automatically merge, and report any conflicts.
102102

103-
Ordinarily, a commit has exactly one parent, namely, the previous commit.
104-
Merging other branches creates a commit with at least two parents. This begs
105-
the question: what commit does `HEAD~10` really refer to? A commit could have
106-
multiple parents, so which one do we follow?
103+
Ordinarily, a commit has exactly one 'parent commit', namely, the previous
104+
commit. Merging branches together produces a commit with at least two parents.
105+
This begs the question: what commit does `HEAD~10` really refer to? A commit
106+
could have multiple parents, so which one do we follow?
107107

108-
It turns out we follow the first parent at every step. This is usually desired,
109-
because commits in the current branch always become first parents in a *git
110-
merge*; frequently you're only concerned with the changes you made in the
108+
It turns out this notation chooses the first parent every time. This is
109+
desirable because commits in the current branch become the first parents during
110+
a merge; frequently you're only concerned with the changes you made in the
111111
current branch, as opposed to changes merged in from other branches.
112112

113113
You can refer to a specific parent with a caret. For example, to show
114114
the logs from the second parent:
115115

116116
$ git log HEAD^2
117117

118-
If you want the first parent, you can leave out the number. For example, to
119-
show the differences with the first parent:
118+
You may omit the number for the first parent. For example, to show the
119+
differences with the first parent:
120120

121121
$ git diff HEAD^
122122

123123
You can combine this notation with other types. For example:
124124

125-
$ git checkout 1bd6^^2~10 -b ancient
125+
$ git checkout 1b6d^^2~10 -b ancient
126126

127127
starts a new branch ``ancient'' representing the state 10 commits back from the
128-
second parent of the first parent of the commit starting with 1bd6.
128+
second parent of the first parent of the commit starting with 1b6d.
129129

130130
=== Uninterrupted Workflow ===
131131

@@ -230,14 +230,14 @@ You can have multiple stashes, and manipulate them in various ways. See
230230
=== Work How You Want ===
231231

232232
You might wonder if branches are worth the bother. After all, clones are almost
233-
as fast, and you can use *cd* to switch between them, instead of esoteric Git
233+
as fast, and you can switch between them with *cd* instead of esoteric Git
234234
commands.
235235

236236
Consider web browsers. Why support multiple tabs as well as multiple windows?
237237
Because allowing both accommodates a wide variety of styles. Some users like to
238238
keep only one browser window open, and use tabs for multiple webpages. Others
239239
might insist on the other extreme: multiple windows with no extra tabs anywhere.
240-
Yet others prefer something in between.
240+
Others still prefer something in between.
241241

242242
Branching is like tabs for your working directory, and cloning is like opening
243243
a new browser window. These operations are fast and local, so why not

en/clone.txt

+38-15
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
In older version control systems, checkout is the standard operation to get files. You retrieve a bunch of files in the requested saved state.
44

5-
In Git and other distributed version control systems, cloning is the standard operation. To get files you create a clone of the entire repository. In other words, you practically mirror the central server. Anything the main repository can do, you can do.
5+
In Git and other distributed version control systems, cloning is the standard operation. To get files, you create a 'clone' of the entire repository. In other words, you practically mirror the central server. Anything the main repository can do, you can do.
66

77
=== Sync Computers ===
88

9-
This is the reason I first used Git. I can tolerate making tarballs or using *rsync* for backups and basic syncing. But sometimes I edit on my laptop, other times on my desktop, and the two may not have talked to each other in between.
9+
I can tolerate making tarballs or using *rsync* for backups and basic syncing. But sometimes I edit on my laptop, other times on my desktop, and the two may not have talked to each other in between. This situation drove me to learn Git in the first place.
1010

1111
Initialize a Git repository and commit your files on one machine. Then on the other:
1212

@@ -17,7 +17,7 @@ to create a second copy of the files and Git repository. From now on,
1717
$ git commit -a
1818
$ git pull other.computer:/path/to/files HEAD
1919

20-
will pull in the state of the files on the other computer into the one you're working on. If you've recently made conflicting edits in the same file, Git will let you know and you should commit again after resolving them.
20+
will 'pull' in the state of the files on the other computer into the one you're working on. If you've recently made conflicting edits in the same file, Git will let you know and you should commit again after resolving them.
2121

2222
=== Classic Source Control ===
2323

@@ -27,38 +27,61 @@ Initialize a Git repository for your files:
2727
$ git add .
2828
$ git commit -m "Initial commit"
2929

30-
On the central server, initialize an empty Git repository with some name,
31-
and start the Git daemon if necessary:
30+
On the central server, initialize a 'bare repository' in some directory:
3231

33-
$ GIT_DIR=proj.git git init
34-
$ git daemon --detach # it might already be running
32+
$ mkdir proj.git
33+
$ cd proj.git
34+
$ git init --bare
35+
$ # one-liner alternative: GIT_DIR=proj.git git init
36+
37+
Start the Git daemon if necessary:
38+
39+
$ git daemon --detach # it may already be running
3540

3641
For Git hosting services, follow the instructions to setup the initially
3742
empty Git repository. Typically one fills in a form on a webpage.
3843

39-
Push your project to the central server with:
44+
'Push' your project to the central server with:
4045

4146
$ git push git://central.server/path/to/proj.git HEAD
4247

43-
The central server now holds a 'bare repository': a repository with no working directory. In other words, the central server has the history of your project, but never contains a snapshot of it. To check out the source, a developer types:
48+
The bare repository is so named because it contains no working directory and exposes files that are hidden away in the `.git` subdirectory of a normal Git repository. In other words, the central server maintains the history of your project, and never carries a snapshot of any given version.
49+
50+
To check out the source, a developer types:
4451

4552
$ git clone git://central.server/path/to/proj.git
4653

47-
After making changes, the code is checked in to the main server by:
54+
After making changes, the developer saves changes locally:
4855

4956
$ git commit -a
50-
$ git push
5157

52-
If the main server has been updated, the latest version needs to be checked out before the push. To sync to the latest version:
58+
To update to the latest version:
5359

54-
$ git commit -a
5560
$ git pull
5661

62+
Any merge conflicts should be resolved then committed:
63+
64+
$ git commit -a
65+
66+
To check in local changes into the central repository:
67+
68+
$ git push
69+
70+
If the main server has new changes due to activity by other developers, the
71+
push fails, and the developer should pull the latest version, resolve any merge
72+
conflicts, then try again.
73+
5774
=== Push versus pull ===
5875

59-
A push is more convenient than a pull in the above example. If we pulled from the server, we would have to login to the server first, and give the pull command the network address of the machine we're pulling from. Firewalls may interfere, and we might not even have shell access to the server.
76+
A push is more convenient than a pull in the above example. Firstly, pull fails
77+
on bare repositories (you must 'fetch' instead; we discuss this in a later
78+
chapter). But even if we kept a normal repository on the central server,
79+
pulling into it is still cumbersome. Each time, we would have to login to the
80+
server first, and give the pull command the network address of the machine
81+
we're pulling from. Firewalls may interfere, and we might not even have shell
82+
access to the server.
6083

61-
However, we usually avoid pushing into a repository, because confusion can ensue if the destination has a working directory with changes. But since a bare repository by definition has no working directory, pushing to a bare repository is a straightforward operation.
84+
However, apart from this case, we discourage pushing into a repository, because confusion can ensue when the destination has a working directory.
6285

6386
In short, while learning Git, only push when the target is a bare repository; otherwise pull.
6487

en/grandmaster.txt

+10-8
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ But how can you go back to the future? The past commits know nothing of the futu
8686

8787
If you have the SHA1 of the original HEAD then:
8888

89-
$ git reset 1bd6
89+
$ git reset 1b6d
9090

91-
But suppose you never took it down? Don't worry, for commands like these, Git saves the original HEAD as a tag called ORIG_HEAD, and you can return safe and sound with:
91+
But suppose you never took it down? Don't worry: for commands like these, Git saves the original HEAD as a tag called ORIG_HEAD, and you can return safe and sound with:
9292

9393
$ git reset ORIG_HEAD
9494

@@ -161,7 +161,7 @@ One popular resident is +workdir/git-new-workdir+. Via clever symlinking, this s
161161

162162
$ git-new-workdir an/existing/repo new/directory
163163

164-
The new directory and files within can be thought of as a clone, except since the history is shared, the two trees automatically stay in sync. There's no need to merge, push or pull.
164+
The new directory and the files within can be thought of as a clone, except since the history is shared, the two trees automatically stay in sync. There's no need to merge, push or pull.
165165

166166
=== Daring Stunts ===
167167

@@ -177,7 +177,7 @@ On the other hand, if you specify particular paths for checkout, then there are
177177

178178
*Reset*: Reset also fails in the presence of uncommitted changes. To force it through, run:
179179

180-
$ git reset --hard 1bd6
180+
$ git reset --hard 1b6d
181181

182182
*Branch*: Deleting branches fails if this causes changes to be lost. To force a deletion, type:
183183

@@ -200,10 +200,10 @@ directories are expendable, then delete them mercilessly with:
200200

201201
Next time, that pesky command will work!
202202

203-
=== Improve Your Public Image ===
203+
=== Preventing Bad Commits ===
204204

205205
Stupid mistakes abound in the histories of many of my projects. The most
206-
frightening are missing files due to forgetting to run *git add*. Luckily I
206+
frightening are missing files due to a forgotten *git add*. Luckily I
207207
have yet to lose crucial data though accidental omission because I rarely
208208
delete original working directories. I typically notice the error a few commits
209209
later, so the only damage is a bit of missing history and a sheepish admission
@@ -238,5 +238,7 @@ Several git operations support hooks; see *git help hooks*. One can write hooks
238238
to complain about spelling mistakes in commit messages, add new files, indent
239239
paragraphs, append an entry to a webpage, play a sound, and so on.
240240

241-
We encountered the *post-update* hook earlier when discussing Git over
242-
HTTP. This hook updates a few files Git needs for non-native communication.
241+
We activated the sample *post-update* hook earlier when discussing Git over
242+
HTTP; this causes Git to run this script whenever the head has moved. The
243+
sample post-update script updates a few files Git needs for communication over
244+
Git-agnostic transports such as HTTP.

en/history.txt

+11-12
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ history which you alone possess. Just as nations forever argue over who
66
committed what atrocity, if someone else has a clone whose version of history
77
differs to yours, you will have trouble reconciling when your trees interact.
88

9-
Of course, if you control all the other trees too, you can simply overwrite
10-
them.
11-
129
Some developers strongly feel history should be immutable, warts and all.
1310
Others feel trees should be made presentable before they are unleashed in
1411
public. Git accommodates both viewpoints. Like cloning, branching and merging,
@@ -44,20 +41,22 @@ Then:
4441

4542
- Remove commits by deleting lines.
4643
- Reorder commits by reordering lines.
47-
- Replace "pick" with "edit" to mark a commit for amending.
48-
- Replace "pick" with "reword" to change the log message.
49-
- Replace "pick" with "squash" to merge a commit with the previous one.
50-
- Replace "pick" with "fixup" to merge a commit with the previous one and discard the log message.
44+
- Replace `pick` with:
45+
* `edit` to mark a commit for amending.
46+
* `reword` to change the log message.
47+
* `squash` to merge a commit with the previous one.
48+
* `fixup` to merge a commit with the previous one and discard the log message.
5149

52-
If you marked a commit for editing, then run:
50+
Save and quit. If you marked a commit for editing, then
51+
run:
5352

5453
$ git commit --amend
5554

5655
Otherwise, run:
5756

5857
$ git rebase --continue
5958

60-
So commit early and commit often: you can easily tidy up later with rebase.
59+
So commit early and commit often: you can tidy up later with rebase.
6160

6261
=== Local Changes Last ===
6362

@@ -147,9 +146,9 @@ You can checkout the latest version of the project with:
147146

148147
$ git checkout master .
149148

150-
The *git fast-export* command converts any git repository to the
149+
The *git fast-export* command converts any repository to the
151150
*git fast-import* format, whose output you can study for writing exporters,
152-
and also to transport git repositories in a human-readable format. Indeed,
151+
and also to transport repositories in a human-readable format. Indeed,
153152
these commands can send repositories of text files over text-only channels.
154153

155154
=== Where Did It All Go Wrong? ===
@@ -161,7 +160,7 @@ can pinpoint the problem:
161160

162161
$ git bisect start
163162
$ git bisect bad HEAD
164-
$ git bisect good 1bd6
163+
$ git bisect good 1b6d
165164

166165
Git checks out a state halfway in between. Test the feature, and if it's still broken:
167166

0 commit comments

Comments
 (0)