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

Commit History Master

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

Git Gui Prune Origin

Paths

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

Documentation / Reference





Discover More
Git - Clone

git clone creates a clone known as local repository from a remote repository. cloning in git means: downloading the remote repository into a newly created directory setting for each downloaded branch...
Git - Tracking Branch

Tracking branches are local branches that have set their upstream branch. tracking branchreference The local branches have then a direct relationship with their upstream branch that can be: a remote...
Branches Git
Git - Branch

This page talks Branch management in Git. For Git, a branch is: a commit name (ref) that points to the last commit (head) leaf in the commit log (or log) that represents a commit chain Example...
What is a Git Checkout?

With a checkout, you can change the current branch (ie switch branches) or extract files/directory from branches into the working tree (file system directory) files. ie: Restore the file state from...



Share this page:
Follow us:
Task Runner