Git - Remote-tracking branch

1 - About

Remote-tracking branches are local references to the state of remote branches

  • You can't modify them. They’re just local references that you can’t move.
  • They represent the state of the remote repository the last time you connected to them

They are a local cache of the remote branches.

3 - Syntax

Remote-tracking branches take the form <remote>/<branch>

4 - Example

origin/master and remote/master are two remote-tracking branch.


git remote add remote https://aRemoteUrl
  • the remote where fetched with the following statement
git fetch origin
git fetch remote

5 - Management

5.1 - List

git branch --remotes
# or
git branch -r
* master

5.2 - Update

Update the remote tracking branch with the modification on the remote branch

git fetch

git pull is used behind the scene

5.3 - Delete

5.3.1 - One

git branch -rd <remote>/<branchname>

5.3.2 - Prune

To delete all remote-tracking branches that are stale ie where the corresponding branches on the remote machine no longer exist:

git remote prune <remote>

With git-gui, Remote > Prune

5.4 - Paths

Each remote-tracking branch has a file under .git/refs/<remote>/

6 - Documentation / Reference

code/version/git/remote-tracking.txt · Last modified: 2018/07/17 12:28 by gerardnico