Answer the question
In order to leave comments, you need to log in
How to add someone else's branch to a project?
There is a master branch and my own, which I created.
But there is another branch in the project develop
that is not visible.
When the git branch command gives me only two branches, master and mine, and the command git branch -a
shows that there is also develop and others.
I ran the git fetch command, but the branches were not added.
How do I add a branch develop
which, after the command git branch -a
, is displayed as
remotes/origin/develop
Answer the question
In order to leave comments, you need to log in
This is called not to add, but to unpack the branch into the working directory from the local repository (make it current), into which it has already been loaded (added) with the fetch command.
git checkout -b develop origin/develop --
And that's it. After checkout you will be able to work with this branch.
remotes/origin/develop
means that the branch exists in the remote repository.
Simply switch to the branch is enough:
git checkout develop
If the branch exists locally, git will switch to it, if it does not exist locally, but it is in the remote repository, git will download it and switch to it (and the branch will appear locally). If there is no branch either locally or remotely, there will be an error.
You want to create a local branch KUKU that tracks the remote branch origin/KUKU .
git checkout --track origin/KUKU
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question