Skip to content

Commit 8e4b434

Browse files
committed
Edits, part I
1 parent 3ba0bca commit 8e4b434

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

en/book/03-git-branching/chapter3.asc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ If you make some changes and commit again, the next commit stores a pointer to t
3232
.Git object data for multiple commits
3333
image::images/18333fig0302-tn.png[Git object data for multiple commits.]
3434

35-
A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master. As you initially make commits, you’re given a master branch that points to the last commit you made. Every time you commit, it moves forward automatically.
35+
A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is `master`. As you start making commits, you’re given a master branch that points to the last commit you made. Every time you commit, it moves forward automatically.
3636

3737
.Branch pointing into the commit data’s history
3838
image::images/18333fig0303-tn.png[Branch pointing into the commit data’s history.]
@@ -50,7 +50,7 @@ This creates a new pointer at the same commit you’re currently on (see <<histo
5050
.Multiple branches pointing into the commit’s data history
5151
image::images/18333fig0304-tn.png[Multiple branches pointing into the commit’s data history.]
5252

53-
How does Git know what branch you’re currently on? It keeps a special pointer called HEAD. Note that this is a lot different than the concept of HEAD in other VCSs you may be used to, such as Subversion or CVS. In Git, this is a pointer to the local branch you’re currently on. In this case, you’re still on master. The git branch command only created a new branch – it didn’t switch to that branch (see <<history_diagram_b>>).
53+
How does Git know what branch you’re currently on? It keeps a special pointer called `HEAD`. Note that this is a lot different than the concept of `HEAD` in other VCSs you may be used to, such as Subversion or CVS. In Git, this is a pointer to the local branch you’re currently on. In this case, you’re still on master. The `git branch` command only _created_ a new branch – it didn’t switch to that branch (see <<history_diagram_b>>).
5454

5555
[[history_diagram_b]]
5656
.HEAD file pointing to the branch you’re on
@@ -63,7 +63,7 @@ To switch to an existing branch, you run the `git checkout` command. Let’s swi
6363
$ git checkout testing
6464
----
6565

66-
This moves HEAD to point to the testing branch (see <<history_diagram_c>>).
66+
This moves `HEAD` to point to the `testing` branch (see <<history_diagram_c>>).
6767

6868
[[history_diagram_c]]
6969
.HEAD points to another branch when you switch branches
@@ -96,7 +96,7 @@ $ git checkout master
9696
.HEAD moves to another branch on a checkout
9797
image::images/18333fig0308-tn.png[HEAD moves to another branch on a checkout.]
9898

99-
That command did two things. It moved the HEAD pointer back to point to the master branch, and it reverted the files in your working directory back to the snapshot that master points to. This also means the changes you make from this point forward will diverge from an older version of the project. It essentially rewinds the work you’ve done in your testing branch temporarily so you can go in a different direction.
99+
That command did two things. It moved the HEAD pointer back to point to the master branch, and it reverted the files in your working directory back to the snapshot that master points to. This also means the changes you make from this point forward will diverge from an older version of the project. It essentially rewinds the work you’ve done in your testing branch so you can go in a different direction.
100100

101101
Let’s make a few changes and commit again:
102102

@@ -106,14 +106,14 @@ $ vim test.rb
106106
$ git commit -a -m 'made other changes'
107107
----
108108

109-
Now your project history has diverged (see Figure 3-9). You created and switched to a branch, did some work on it, and then switched back to your main branch and did other work. Both of those changes are isolated in separate branches: you can switch back and forth between the branches and merge them together when you’re ready. And you did all that with simple `branch` and `checkout` commands.
109+
Now your project history has diverged (see Figure 3-9). You created and switched to a branch, did some work on it, and then switched back to your main branch and did other work. Both of those changes are isolated in separate branches: you can switch back and forth between the branches and merge them together when you’re ready. And you did all that with simple `branch`, `checkout`, and `commit` commands.
110110

111111
.The branch histories have diverged
112112
image::images/18333fig0309-tn.png[The branch histories have diverged.]
113113

114114
Because a branch in Git is in actuality a simple file that contains the 40 character SHA-1 checksum of the commit it points to, branches are cheap to create and destroy. Creating a new branch is as quick and simple as writing 41 bytes to a file (40 characters and a newline).
115115

116-
This is in sharp contrast to the way most VCS tools branch, which involves copying all of the project’s files into a second directory. This can take several seconds or even minutes, depending on the size of the project, whereas in Git the process is always instantaneous. Also, because we’re recording the parents when we commit, finding a proper merge base for merging is automatically done for us and is generally very easy to do. These features help encourage developers to create and use branches often.
116+
This is in sharp contrast to the way most older VCS tools branch, which involves copying all of the project’s files into a second directory. This can take several seconds or even minutes, depending on the size of the project, whereas in Git the process is always instantaneous. Also, because we’re recording the parents when we commit, finding a proper merge base for merging is automatically done for us and is generally very easy to do. These features help encourage developers to create and use branches often.
117117

118118
Let’s see why you should do so.
119119

0 commit comments

Comments
 (0)