git add remote a developer's local branch
-
18-06-2021 - |
Question
How does one add a local branch from that of another developer? My colleague's branch is not out on origin.
Thanks!
La solution
First, add a "remote" (like a nickname for a repository URL) for your colleague's repository:
git remote add colleague <URL-of-their-repository>
Then fetch all the branches from that repository into remote tracking branches called refs/remotes/colleague/<branch-name>
(which can usually be abbreviated to colleague/<branch-name>
):
git fetch colleague
Now create (and switch to) a local branch called foo
which tracks your colleague's branch called foo
with:
git checkout --track colleague/foo
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow