Git - Remote-tracking branch

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.

Syntax

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

Example

_

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

where:

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

Management

List

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

Update

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

git fetch

git pull is used behind the scene

Delete

One

git branch -rd <remote>/<branchname>

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

_

Paths

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

Documentation / Reference


Powered by ComboStrap