User Tools

Site Tools


git_remote_tracking_branches

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
git_remote_tracking_branches [2019/03/07 15:58]
rpjday [Terminology]
git_remote_tracking_branches [2019/03/07 19:38]
rpjday
Line 5: Line 5:
 ===== Terminology ===== ===== Terminology =====
  
-  * ''​master'':​ local tracking branch +  * ''​master'':​ local tracking branch ​(in local object store) 
-  * ''​origin/​master'':​ remote tracking branch+  * ''​origin/​master'':​ remote tracking branch ​(in local object store)
   * ''​master''​ on remote system: remote branch   * ''​master''​ on remote system: remote branch
 +
 +All of these branches can be "out of sync" with one another.
  
 ===== Simple example ===== ===== Simple example =====
Line 19: Line 21:
  
 nothing to commit, working tree clean nothing to commit, working tree clean
 +$
 +</​code>​
 +
 +<​code>​
 +$ git show master
 +commit 1c163f4c7b3f621efff9b28a47abb36f7378d783 (HEAD -> master, tag: v5.0, origin/​master,​ origin/​HEAD)
 +Author: Linus Torvalds <​torvalds@linux-foundation.org>​
 +Date:   Sun Mar 3 15:21:29 2019 -0800
 +
 +    Linux 5.0
 +
 +diff --git a/Makefile b/Makefile
 +index ac5ac28a24e9..d5713e7b1e50 100644
 +--- a/Makefile
 ++++ b/Makefile
 +@@ -2,7 +2,7 @@
 + ​VERSION = 5
 + ​PATCHLEVEL = 0
 + ​SUBLEVEL = 0
 +-EXTRAVERSION = -rc8
 ++EXTRAVERSION =
 + NAME = Shy Crocodile
 + 
 + # *DOCUMENTATION*
 +$
 +</​code>​
 +
 +<​code>​
 +$ git show origin/​master
 +commit 1c163f4c7b3f621efff9b28a47abb36f7378d783 (HEAD -> master, tag: v5.0, origin/​master,​ origin/​HEAD)
 +Author: Linus Torvalds <​torvalds@linux-foundation.org>​
 +Date:   Sun Mar 3 15:21:29 2019 -0800
 +
 +    Linux 5.0
 +
 +diff --git a/Makefile b/Makefile
 +index ac5ac28a24e9..d5713e7b1e50 100644
 +--- a/Makefile
 ++++ b/Makefile
 +@@ -2,7 +2,7 @@
 + ​VERSION = 5
 + ​PATCHLEVEL = 0
 + ​SUBLEVEL = 0
 +-EXTRAVERSION = -rc8
 ++EXTRAVERSION =
 + NAME = Shy Crocodile
 + 
 + # *DOCUMENTATION*
 +$
 +</​code>​
 +
 +Fetch, but do not merge, which updates the remote tracking branch, but not the local tracking branch:
 +
 +<​code>​
 +$ git fetch
 +remote: Counting objects: 53547, done.
 +remote: Compressing objects: 100% (20826/​20826),​ done.
 +remote: Total 53547 (delta 38450), reused 43614 (delta 32435)
 +Receiving objects: 100% (53547/​53547),​ 41.90 MiB | 11.16 MiB/s, done.
 +Resolving deltas: 100% (38450/​38450),​ done.
 +From https://​git.kernel.org/​pub/​scm/​linux/​kernel/​git/​torvalds/​linux
 +   ​1c163f4c7b3f..1fc1cd8399ab ​ master ​    -> origin/​master
 +$
 +</​code>​
 +
 +''​git status''​ will now show that you are considerably behind the remote tracking branch:
 +
 +<​code>​
 +$ git status
 +On branch master
 +Your branch is behind '​origin/​master'​ by 6622 commits, and can be fast-forwarded.
 +  (use "git pull" to update your local branch)
 +
 +nothing to commit, working tree clean
 +$
 +</​code>​
 +
 +And you can show the tip of ''​origin/​master'':​
 +
 +<​code>​
 +$ git show origin/​master
 +commit 1fc1cd8399ab5541a488a7e47b2f21537dd76c2d (origin/​master,​ origin/​HEAD)
 +Merge: abf7c3d8ddea 6a613d24effc
 +Author: Linus Torvalds <​torvalds@linux-foundation.org>​
 +Date:   Thu Mar 7 10:11:41 2019 -0800
 +
 +    Merge branch '​for-5.1'​ of git://​git.kernel.org/​pub/​scm/​linux/​kernel/​git/​tj/​cgroup
 +    ​
 +    Pull cgroup updates from Tejun Heo:
 +    ​
 +     - Oleg's pids controller accounting update which gets rid of rcu delay
 +       in pids accounting updates
 +    ​
 +     - rstat (cgroup hierarchical stat collection mechanism) optimization
 +    ​
 +     - Doc updates
 +    ​
 +    * '​for-5.1'​ of git://​git.kernel.org/​pub/​scm/​linux/​kernel/​git/​tj/​cgroup:​
 +      cpuset: remove unused task_has_mempolicy()
 +      cgroup, rstat: Don't flush subtree root unless necessary
 +      cgroup: add documentation for pids.events file
 +      Documentation:​ cgroup-v2: eliminate markup warnings
 +      MAINTAINERS:​ Update cgroup entry
 +      cgroup/​pids:​ turn cgroup_subsys->​free() into cgroup_subsys->​release() to fix the accounting
 +$
 +</​code>​
 +
 +===== Working with a remote tracking branch =====
 +
 +You can treat a remote tracking branch just like any other branch in that you can look, compare, cherry-pick and so on, but you can't check it out to make changes to it:
 +
 +<​code>​
 +$ git checkout origin/​master
 +Checking out files: 100% (6413/​6413),​ done.
 +Note: checking out '​origin/​master'​.
 +
 +You are in '​detached HEAD' state. You can look around, make experimental
 +changes and commit them, and you can discard any commits you make in this
 +state without impacting any branches by performing another checkout.
 +
 +If you want to create a new branch to retain commits you create, you may
 +do so (now or later) by using -b with the checkout command again. Example:
 +
 +  git checkout -b <​new-branch-name>​
 +
 +HEAD is now at 1fc1cd8399ab Merge branch '​for-5.1'​ of git://​git.kernel.org/​pub/​scm/​linux/​kernel/​git/​tj/​cgroup
 +$
 +</​code>​
 +
 +If you want to incorporate all of that into your local tracking branch, you can just:
 +
 +<​code>​
 +$ git checkout master
 +$ git merge origin/​master
 </​code>​ </​code>​
git_remote_tracking_branches.txt · Last modified: 2019/03/08 09:43 by rpjday