Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

How can I find out which remote branch a local branch is tracking?

Do I need to parse git config output, or is there a command that would do this for me?

2 Answers

0 votes
by (50.2k points)

There is a command that gives you about all tracking branches.

git branch -vv

And to know about the pull and push configuration per branch you can use the command git remote show origin.

In git version 1.8.5 you can see the upstream batch with:

git status

and you can use -sb option for seeing the upstream.

Hope this information will help you to find which branch is tracking.

0 votes
by (1.9k points)

To know which remote branch a local branch is tracking in Git, you can use the following command:


 

git branch -vv

This will show all local branches, their tracking branches, and the latest commit message. Look for your branch in the output, and you'll see the remote branch it's tracking next to it.

Alternatively, to check which tracking branch a specific local branch is tracking, you can utilize the following command line:

git rev-parse --abbrev-ref <local-branch-name>@{upstream}

Replace <local-branch-name> with the name of your local branch. This will print the name of the remote branch that it is tracking.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...