Git

Find out Which Remote Branch a Local Branch is Tracking

When developers connect a remote hosting service with the local repository by cloning it, they need to set the tracking branch for tracking data from remote to local, similarly local to remote hosting service. When the remote repository is cloned into the local repository, all the existing remote branches are automatically tracked and set all branches upstream for new checked out. Moreover, users can check the current tracking branch name list whenever needed.

This blog will provide the method of finding which remote branch a local branch is tracking.

How do Find out Which Remote Branch a Local Branch is Tracking?

To find out which remote branch a local branch is tracking, multiple Git commands are used, such as:

  • $ git branch -vv” command
  • $ git -avv” command
  • $ git status” command

Let’s move ahead and check out the results of the above-listed commands!

First, run the “cd” command and move to the Git root directory:

$ cd "C:\Users\nazma\Git"

To view the remote branch a local branch is tracking, use the “git branch” command:

$ git branch -vv

As you can see, the below-highlighted “origin/master” branch is the remote tracking branch:

Another way to display the tracking branch is using the “git branch” command along with the “-avv” option:

$ git branch -avv

Here, the below-highlighted branch is the remote-tracking branch of a local branch:

You can also get the name of the remote branch which is tracking a local branch by checking the current repository status:

$ git status

That was all about finding the remote branch which is tracking a local branch.

Conclusion

To find out which remote branch a local branch is tracking, multiple Git commands are used, such as “$ git branch -vv”, “$ git -avv” and “$ git status” commands. To utilize these commands, move to the required Git local repository and run any of the mentioned commands. This blog demonstrated the method to find out which remote branch a local branch is tracking.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.