You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/03-git-branching/sections/basic-branching-and-merging.asc
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ All you have to do is switch back to your `master` branch.
63
63
However, before you do that, note that if your working directory or staging area has uncommitted changes that conflict with the branch you're checking out, Git won't let you switch branches.
64
64
It's best to have a clean working state when you switch branches.
65
65
There are ways to get around this (namely, stashing and commit amending) that we'll cover later on, in <<_git_stashing>>.
66
-
For now, let's assume you've committed all your changes, so you can switch back to your master branch:
66
+
For now, let's assume you've committed all your changes, so you can switch back to your `master` branch:
67
67
68
68
[source,console]
69
69
----
@@ -91,7 +91,7 @@ $ git commit -a -m 'fixed the broken email address'
91
91
.Hotfix branch based on `master`
92
92
image::images/basic-branching-4.png[Hotfix branch based on `master`.]
93
93
94
-
You can run your tests, make sure the hotfix is what you want, and merge it back into your master branch to deploy to production.
94
+
You can run your tests, make sure the hotfix is what you want, and merge it back into your `master` branch to deploy to production.
95
95
You do this with the `git merge` command:(((git commands, merge)))
Copy file name to clipboardExpand all lines: book/03-git-branching/sections/nutshell.asc
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ image::images/commits-and-parents.png[Commits and their parents.]
32
32
33
33
A branch in Git is simply a lightweight movable pointer to one of these commits.
34
34
The default branch name in Git is `master`.
35
-
As you start making commits, you're given a master branch that points to the last commit you made.
35
+
As you start making commits, you're given a `master` branch that points to the last commit you made.
36
36
Every time you commit, it moves forward automatically.
37
37
38
38
[NOTE]
@@ -68,7 +68,7 @@ How does Git know what branch you're currently on?
68
68
It keeps a special pointer called `HEAD`.
69
69
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.
70
70
In Git, this is a pointer to the local branch you're currently on.
71
-
In this case, you're still on master.
71
+
In this case, you're still on `master`.
72
72
The `git branch` command only _created_ a new branch – it didn't switch to that branch.
73
73
74
74
.HEAD pointing to a branch
@@ -92,7 +92,7 @@ You can see the ``master'' and ``testing'' branches that are right there next to
92
92
93
93
(((branches, switching)))
94
94
To switch to an existing branch, you run the `git checkout` command.(((git commands, checkout)))
95
-
Let's switch to the new testing branch:
95
+
Let's switch to the new `testing` branch:
96
96
97
97
[source,console]
98
98
----
@@ -116,8 +116,8 @@ $ git commit -a -m 'made a change'
116
116
.The HEAD branch moves forward when a commit is made
117
117
image::images/advance-testing.png[The HEAD branch moves forward when a commit is made.]
118
118
119
-
This is interesting, because now your testing branch has moved forward, but your master branch still points to the commit you were on when you ran `git checkout` to switch branches.
120
-
Let's switch back to the master branch:
119
+
This is interesting, because now your `testing` branch has moved forward, but your `master` branch still points to the commit you were on when you ran `git checkout` to switch branches.
120
+
Let's switch back to the `master` branch:
121
121
122
122
[source,console]
123
123
----
@@ -128,9 +128,9 @@ $ git checkout master
128
128
image::images/checkout-master.png[HEAD moves when you checkout.]
129
129
130
130
That command did two things.
131
-
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.
131
+
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.
132
132
This also means the changes you make from this point forward will diverge from an older version of the project.
133
-
It essentially rewinds the work you've done in your testing branch so you can go in a different direction.
133
+
It essentially rewinds the work you've done in your `testing` branch so you can go in a different direction.
134
134
135
135
[NOTE]
136
136
.Switching branches changes files in your working directory
Copy file name to clipboardExpand all lines: book/03-git-branching/sections/rebasing.asc
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ It works by going to the common ancestor of the two branches (the one you're on
37
37
.Rebasing the change introduced in `C4` onto `C3`
38
38
image::images/basic-rebase-3.png[Rebasing the change introduced in `C4` onto `C3`.]
39
39
40
-
At this point, you can go back to the master branch and do a fast-forward merge.
40
+
At this point, you can go back to the `master` branch and do a fast-forward merge.
41
41
42
42
[source,console]
43
43
----
@@ -72,7 +72,7 @@ Finally, you went back to your server branch and did a few more commits.
72
72
image::images/interesting-rebase-1.png[A history with a topic branch off another topic branch.]
73
73
74
74
Suppose you decide that you want to merge your client-side changes into your mainline for a release, but you want to hold off on the server-side changes until it's tested further.
75
-
You can take the changes on client that aren't on server (`C8` and `C9`) and replay them on your master branch by using the `--onto` option of `git rebase`:
75
+
You can take the changes on client that aren't on server (`C8` and `C9`) and replay them on your `master` branch by using the `--onto` option of `git rebase`:
76
76
77
77
[source,console]
78
78
----
@@ -85,7 +85,7 @@ It's a bit complex, but the result is pretty cool.
85
85
.Rebasing a topic branch off another topic branch
86
86
image::images/interesting-rebase-2.png[Rebasing a topic branch off another topic branch.]
87
87
88
-
Now you can fast-forward your master branch (see <<rbdiag_g>>):
88
+
Now you can fast-forward your `master` branch (see <<rbdiag_g>>):
89
89
90
90
[source,console]
91
91
----
@@ -98,7 +98,7 @@ $ git merge client
98
98
image::images/interesting-rebase-3.png[Fast-forwarding your master branch to include the client branch changes.]
99
99
100
100
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`):
Copy file name to clipboardExpand all lines: book/03-git-branching/sections/remote-branches.asc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ If you run `git clone -o booyah` instead, then you will have `booyah/master` as
30
30
.Server and local repositories after cloning
31
31
image::images/remote-branches-1.png[Server and local repositories after cloning.]
32
32
33
-
If you do some work on your local master branch, and, in the meantime, someone else pushes to `git.ourcompany.com` and updates its `master` branch, then your histories move forward differently.
33
+
If you do some work on your local `master` branch, and, in the meantime, someone else pushes to `git.ourcompany.com` and updates its `master` branch, then your histories move forward differently.
34
34
Also, as long as you stay out of contact with your origin server, your `origin/master` pointer doesn't move.
Copy file name to clipboardExpand all lines: book/03-git-branching/sections/workflows.asc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ You did a few commits on them and deleted them directly after merging them into
44
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.
45
45
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.
46
46
47
-
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).
47
+
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).
48
48
Your commit history will look something like this:
0 commit comments