I have a problem with git. After having initialized the repository I cannot see the remote repository branches locally. Using the command git branch -r
I see the branches (in red).
How can I access the repository branches so that I can work with them?
Normally this is done using local branches of the same name, although this is not a requirement:
If that local branch doesn't exist, then git will look for the repositories configured on the local (
origin
, in this case... but you could have more than one remote) and see if there is a single remote that has a branch of that name. If this is the case, git then creates the local branch that tracks the remote branch of the same name.Using local branches is ideal because it allows you to do things in them without losing your changes. However , using the remote branch directly without a local branch is also possible:
In this case, git will put you on the revision that branch is working on without a local branch . This is called being in
detached HEAD
. This allows you to do everything you normally do in git (merge, cherry-pick, commit, etc) with the exception that there is no local branch being moved as usual. And it's one of the most powerful tools in git (and it has a lot of very powerful tools) as it allows you to move to a remote branch without creating a local branch.Side note: there is no reason for you to put the image in the question. Copy the text and paste it into the question. If you don't know how to format it, no problem, place the text anyway. Some moderator will show up and format it correctly.