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/remote-branches.asc
+11-7Lines changed: 11 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,13 @@
2
2
=== Remote Branches
3
3
4
4
(((branches, remote)))(((references, remote)))
5
-
Remote branches are references (pointers) to the state of branches in your remote repositories.
6
-
They're local branches that you can't move; they're moved automatically for you whenever you do any network communication.
7
-
Remote branches act as bookmarks to remind you where the branches on your remote repositories were the last time you connected to them.
5
+
Remote references are references (pointers) in your remote repositories, including branches, tags, and so on.
6
+
You can get a full list of remote references explicitly with `git ls-remote (remote)`, or `git remote show (remote)` for remote branches as well as more information.
7
+
Nevertheless, a more common way is to take the advantage of remote-tracking branches.
8
+
9
+
Remote-tracking branches are references to the state of remote branches.
10
+
They're local references that you can't move; they're moved automatically for you whenever you do any network communication.
11
+
Remote-tracking act as bookmarks to remind you where the branches in your remote repositories were the last time you connected to them.
8
12
9
13
They take the form `(remote)/(branch)`.
10
14
For instance, if you wanted to see what the `master` branch on your `origin` remote looked like as of the last time you communicated with it, you would check the `origin/master` branch.
@@ -45,7 +49,7 @@ Name this remote `teamone`, which will be your shortname for that whole URL.
45
49
image::images/remote-branches-4.png[Adding another server as a remote.]
46
50
47
51
Now, you can run `git fetch teamone` to fetch everything the remote `teamone` server has that you don't have yet.
48
-
Because that server has a subset of the data your `origin` server has right now, Git fetches no data but sets a remote branch called `teamone/master` to point to the commit that `teamone` has as its `master` branch.
52
+
Because that server has a subset of the data your `origin` server has right now, Git fetches no data but sets a remote-tracking branch called `teamone/master` to point to the commit that `teamone` has as its `master` branch.
49
53
50
54
.Remote tracking branch for `teamone/master`
51
55
image::images/remote-branches-5.png[Remote tracking branch for `teamone/master`.]
@@ -103,11 +107,11 @@ From https://github.com/schacon/simplegit
103
107
* [new branch] serverfix -> origin/serverfix
104
108
----
105
109
106
-
It's important to note that when you do a fetch that brings down new remote branches, you don't automatically have local, editable copies of them.
110
+
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.
107
111
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.
108
112
109
113
To merge this work into your current working branch, you can run `git merge origin/serverfix`.
110
-
If you want your own `serverfix` branch that you can work on, you can base it off your remote branch:
114
+
If you want your own `serverfix` branch that you can work on, you can base it off your remote-tracking branch:
111
115
112
116
[source,console]
113
117
----
@@ -122,7 +126,7 @@ This gives you a local branch that you can work on that starts where `origin/ser
122
126
==== Tracking Branches
123
127
124
128
(((branches, tracking)))(((branches, upstream)))
125
-
Checking out a local branch from a remote branch automatically creates what is called a ``tracking branch'' (or sometimes an ``upstream branch'').
129
+
Checking out a local branch from a remote-tracking branch automatically creates what is called a ``tracking branch'' (or sometimes an ``upstream branch'').
126
130
Tracking branches are local branches that have a direct relationship to a remote branch.
127
131
If you're on a tracking branch and type `git pull`, Git automatically knows which server to fetch from and branch to merge into.
0 commit comments