This is my understanding of Git:-
If I clone a repository then I initially only get a copy of the master branch. I can then indicate that I want to track a remote branch using git checkout with the -b flag. This works as expected.
So my question is how do you get Git to tell you this information. If I type git branch -a then it shows me a mixed list of all the branches e.g.
* master
mybranch
remotes/origin/master
remotes/origin/mybranch
What I want to know is other than maintaining the same name, how can I tell what local branches are tracking what remote ones?
Thanks.
In fact,
git checkout -b ...is what you use to create a new branch. If you simply want to check out a branch that already exists in the remote, you don’t need-b. For example, here I’m creating a local branch that tracksremotes/origin/folder-hack:Each branch has a corresponding configuration in
.git/config. You can find the remote associated with a branch by looking atbranch.<BRANCHNAME>.remote, and you can find the name of the remote branch by looking atbranch.<BRANCHNAME>.merge. So, from my previous example:You can just run
git config --listand look at thebranch...lines.