T
T
Torento203452021-06-07 12:08:07
git
Torento20345, 2021-06-07 12:08:07

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 developthat is not visible.
When the git branch command gives me only two branches, master and mine, and the command git branch -ashows 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 developwhich, 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

5 answer(s)
S
Sergey Kuznetsov, 2021-06-08
@Torento20345

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.

A
Anton, 2021-06-17
@schepetkov

remotes/origin/developmeans 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.

S
Sergey delphinpro, 2021-06-07
@delphinpro

git pull origin develop

D
drtvader, 2021-06-08
@drtvader

Probably work is being done according to git flow

A
Aryeh Leonid R., 2021-06-17
@aryeh

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 question

Ask a Question

731 491 924 answers to any question