Skip to content

Commit 67fd8a9

Browse files
authored
Merge pull request #878 from rpjday/branching
Branching
2 parents 1bb6abb + 982544a commit 67fd8a9

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

book/03-git-branching/sections/basic-branching-and-merging.asc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ Fast-forward
106106

107107
You'll notice the phrase ``fast-forward'' in that merge.
108108
Because the commit `C4` pointed to by the branch `hotfix` you merged in was directly ahead of the commit `C2` you're on, Git simply moves the pointer forward.
109-
To phrase that another way, when you try to merge one commit with a commit that can be reached by following the first commit's history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together this is called a ``fast-forward.''
109+
To phrase that another way, when you try to merge one commit with a commit that can be reached by following the first commit's history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together -- this is called a ``fast-forward.''
110110

111111
Your change is now in the snapshot of the commit pointed to by the `master` branch, and you can deploy the fix.
112112

113113
.`master` is fast-forwarded to `hotfix`
114114
image::images/basic-branching-5.png[`master` is fast-forwarded to `hotfix`.]
115115

116116
After your super-important fix is deployed, you're ready to switch back to the work you were doing before you were interrupted.
117-
However, first you'll delete the `hotfix` branch, because you no longer need it the `master` branch points at the same place.
117+
However, first you'll delete the `hotfix` branch, because you no longer need it -- the `master` branch points at the same place.
118118
You can delete it with the `-d` option to `git branch`:
119119

120120
[source,console]

book/03-git-branching/sections/nutshell.asc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ It keeps a special pointer called `HEAD`.
6969
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.
7070
In Git, this is a pointer to the local branch you're currently on.
7171
In this case, you're still on `master`.
72-
The `git branch` command only _created_ a new branch it didn't switch to that branch.
72+
The `git branch` command only _created_ a new branch -- it didn't switch to that branch.
7373

7474
.HEAD pointing to a branch
7575
image::images/head-to-master.png[HEAD pointing to a branch.]

book/03-git-branching/sections/rebasing.asc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ Now, the snapshot pointed to by `C4'` is exactly the same as the one that was po
5252
There is no difference in the end product of the integration, but rebasing makes for a cleaner history.
5353
If you examine the log of a rebased branch, it looks like a linear history: it appears that all the work happened in series, even when it originally happened in parallel.
5454

55-
Often, you'll do this to make sure your commits apply cleanly on a remote branch perhaps in a project to which you're trying to contribute but that you don't maintain.
55+
Often, you'll do this to make sure your commits apply cleanly on a remote branch -- perhaps in a project to which you're trying to contribute but that you don't maintain.
5656
In this case, you'd do your work in a branch and then rebase your work onto `origin/master` when you were ready to submit your patches to the main project.
57-
That way, the maintainer doesn't have to do any integration work just a fast-forward or a clean apply.
57+
That way, the maintainer doesn't have to do any integration work -- just a fast-forward or a clean apply.
5858

5959
Note that the snapshot pointed to by the final commit you end up with, whether it's the last of the rebased commits for a rebase or the final merge commit after a merge, is the same snapshot – it's only the history that is different.
6060
Rebasing replays changes from one line of work onto another in the order they were introduced, whereas merging takes the endpoints and merges them together.
@@ -98,7 +98,7 @@ $ git merge client
9898
image::images/interesting-rebase-3.png[Fast-forwarding your master branch to include the client branch changes.]
9999

100100
Let's say you decide to pull in your server branch as well.
101-
You can rebase the server branch onto the `master` branch without having to check it out first by running `git rebase <basebranch> <topicbranch>` which checks out the topic branch (in this case, `server`) for you and replays it onto the base branch (`master`):
101+
You can rebase the server branch onto the `master` branch without having to check it out first by running `git rebase <basebranch> <topicbranch>` -- which checks out the topic branch (in this case, `server`) for you and replays it onto the base branch (`master`):
102102

103103
[source,console]
104104
----

book/03-git-branching/sections/remote-branches.asc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ image::images/remote-branches-5.png[Remote tracking branch for `teamone/master`.
6161

6262
(((pushing)))
6363
When you want to share a branch with the world, you need to push it up to a remote that you have write access to.
64-
Your local branches aren't automatically synchronized to the remotes you write to you have to explicitly push the branches you want to share.
64+
Your local branches aren't automatically synchronized to the remotes you write to -- you have to explicitly push the branches you want to share.
6565
That way, you can use private branches for work you don't want to share, and push up only the topic branches you want to collaborate on.
6666

6767
If you have a branch named `serverfix` that you want to work on with others, you can push it up the same way you pushed your first branch.
@@ -82,7 +82,7 @@ To https://github.com/schacon/simplegit
8282
This is a bit of a shortcut.
8383
Git automatically expands the `serverfix` branchname out to `refs/heads/serverfix:refs/heads/serverfix`, which means, ``Take my serverfix local branch and push it to update the remote's serverfix branch.''
8484
We'll go over the `refs/heads/` part in detail in <<_git_internals>>, but you can generally leave it off.
85-
You can also do `git push origin serverfix:serverfix`, which does the same thing it says, ``Take my serverfix and make it the remote's serverfix.''
85+
You can also do `git push origin serverfix:serverfix`, which does the same thing -- it says, ``Take my serverfix and make it the remote's serverfix.''
8686
You can use this format to push a local branch into a remote branch that is named differently.
8787
If you didn't want it to be called `serverfix` on the remote, you could instead run `git push origin serverfix:awesomebranch` to push your local `serverfix` branch to the `awesomebranch` branch on the remote project.
8888

@@ -112,7 +112,7 @@ From https://github.com/schacon/simplegit
112112
----
113113

114114
It's important to note that when you do a fetch that brings down new remote-tracking branches, you don't automatically have local, editable copies of them.
115-
In other words, in this case, you don't have a new `serverfix` branch you only have an `origin/serverfix` pointer that you can't modify.
115+
In other words, in this case, you don't have a new `serverfix` branch -- you only have an `origin/serverfix` pointer that you can't modify.
116116

117117
To merge this work into your current working branch, you can run `git merge origin/serverfix`.
118118
If you want your own `serverfix` branch that you can work on, you can base it off your remote-tracking branch:
@@ -135,7 +135,7 @@ Tracking branches are local branches that have a direct relationship to a remote
135135
If you're on a tracking branch and type `git pull`, Git automatically knows which server to fetch from and branch to merge into.
136136

137137
When you clone a repository, it generally automatically creates a `master` branch that tracks `origin/master`.
138-
However, you can set up other tracking branches if you wish ones that track branches on other remotes, or don't track the `master` branch.
138+
However, you can set up other tracking branches if you wish -- ones that track branches on other remotes, or don't track the `master` branch.
139139
The simple case is the example you just saw, running `git checkout -b <branch> <remote>/<branch>`.
140140
This is a common enough operation that Git provides the `--track` shorthand:
141141

book/03-git-branching/sections/workflows.asc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ In this section, we'll cover some common workflows that this lightweight branchi
99
Because Git uses a simple three-way merge, merging from one branch into another multiple times over a long period is generally easy to do.
1010
This means you can have several branches that are always open and that you use for different stages of your development cycle; you can merge regularly from some of them into others.
1111

12-
Many Git developers have a workflow that embraces this approach, such as having only code that is entirely stable in their `master` branch possibly only code that has been or will be released.
13-
They have another parallel branch named `develop` or `next` that they work from or use to test stability it isn't necessarily always stable, but whenever it gets to a stable state, it can be merged into `master`.
12+
Many Git developers have a workflow that embraces this approach, such as having only code that is entirely stable in their `master` branch -- possibly only code that has been or will be released.
13+
They have another parallel branch named `develop` or `next` that they work from or use to test stability -- it isn't necessarily always stable, but whenever it gets to a stable state, it can be merged into `master`.
1414
It's used to pull in topic branches (short-lived branches, like your earlier `iss53` branch) when they're ready, to make sure they pass all the tests and don't introduce bugs.
1515

1616
In reality, we're talking about pointers moving up the line of commits you're making.
@@ -41,7 +41,7 @@ But in Git it's common to create, work on, merge, and delete branches several ti
4141

4242
You saw this in the last section with the `iss53` and `hotfix` branches you created.
4343
You did a few commits on them and deleted them directly after merging them into your main branch.
44-
This technique allows you to context-switch quickly and completely because your work is separated into silos where all the changes in that branch have to do with that topic, it's easier to see what has happened during code review and such.
44+
This technique allows you to context-switch quickly and completely -- because your work is separated into silos where all the changes in that branch have to do with that topic, it's easier to see what has happened during code review and such.
4545
You can keep the changes there for minutes, days, or months, and merge them in when they're ready, regardless of the order in which they were created or worked on.
4646

4747
Consider an example of doing some work (on `master`), branching off for an issue (`iss91`), working on it for a bit, branching off the second branch to try another way of handling the same thing (`iss91v2`), going back to your `master` branch and working there for a while, and then branching off there to do some work that you're not sure is a good idea (`dumbidea` branch).
@@ -60,4 +60,4 @@ image::images/topic-branches-2.png[History after merging `dumbidea` and `iss91v2
6060
We will go into more detail about the various possible workflows for your Git project in <<_distributed_git>>, so before you decide which branching scheme your next project will use, be sure to read that chapter.
6161

6262
It's important to remember when you're doing all this that these branches are completely local.
63-
When you're branching and merging, everything is being done only in your Git repository no server communication is happening.
63+
When you're branching and merging, everything is being done only in your Git repository -- no server communication is happening.

0 commit comments

Comments
 (0)