Skip to content

Commit 32afb1d

Browse files
committed
add git branch -vv info for inspecting tracking branches
1 parent 4fc35b7 commit 32afb1d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

book/03-git-branching/1-git-branching.asc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,21 @@ Branch serverfix set up to track remote branch serverfix from origin.
765765
When you have an tracking branch set up, you can reference it with the `@{upstream}` or `@{u}` shorthand. So if you're on the `master` branch and it's tracking `origin/master`, you can say something like `git merge @{u}` instead of `git merge origin/master` if you wish.
766766
====
767767

768+
If you want to see what tracking branches you have set up, you can use the `-vv` option to `git branch`. This will list out your local branches with more information including what each branch is tracking and if your local branch is ahead, behind or both.
769+
770+
[source,shell]
771+
----
772+
$ git branch -vv
773+
iss53 7e424c3 [origin/iss53: ahead 2] forgot the brackets
774+
master 1ae2a45 [origin/master] deploying index fix
775+
* serverfix f8674d9 [teamone/server-fix-good: ahead 3, behind 1] this should do it
776+
testing 5ea463a trying something new
777+
----
778+
779+
So here we can see that our `iss53` branch is tracking `origin/iss53` and is ``ahead'' by two, meaning that we have two commits locally that are not pushed to the server. We can also see that our `master` branch is tracking `origin/master` and is up to date. Next we can see that our `serverfix` branch is tracking the `server-fix-good` branch on our `teamone` server and is ahead by three and behind by one, meaning that there is one commit on the server we haven't merged in yet and three commits locally that we haven't pushed. Finally we can see that our `testing` branch is not tracking any remote branch.
780+
781+
It's important to note that these numbers are only since the last time you fetched from each server. This command does not reach out to the servers, it's telling you about what it has cached from these servers locally. If you want totally up to date ahead and behind numbers, you'll need to fetch from all your remotes right before running this. You could do that like this: `$ git fetch --all; git branch -vv`
782+
768783
==== Pulling
769784

770785
While the `git fetch` command will fetch down all the changes on the server that you don't have yet, it will not modify your working directory at all.

0 commit comments

Comments
 (0)