camino
camino

Reputation: 10584

how to check a local branch tracking which remote branch?

I want to check a local branch currently tracking which remote branch

For example:

git checkout -b test_branch
git branch --set-upstream test_branch origin/remote_project001

But after a few days, I forget which remote branch test_branch is tracking. Is there a command that can give me that information?

Upvotes: 1

Views: 660

Answers (1)

Mark Longair
Mark Longair

Reputation: 467201

This is essentially a duplicate, but to briefly repeat that for your situation, you can do the following:

$ git checkout test_branch
$ git rev-parse --abbrev-ref --symbolic-full-name @{u}
origin/remote_project001

If you get the error:

error: No upstream branch found for ''
@{u}
error: No upstream branch found for ''
fatal: ambiguous argument '@{u}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

... then there is no remote-tracking branch configured to be upstream of your current branch.

Upvotes: 4

Related Questions