Reputation: 2811
I created a feature branch using SourceTree and git flow (pressing buttons). Then I tried to clone these branches into another local copy of the repo, but I cannot get these branches locally anymore. For instance if I issue:
git branch -v -a, I see this:
gmmo@DESKTOP-GIMBJM0 MINGW64 /C/Dogwood (develop)
$ git branch -v -a
* develop de5e2f2 Updated to Build 4.1.6.37
master 0aa9613 Release 4.1.6.37
remotes/origin/HEAD -> origin/master
remotes/origin/develop de5e2f2 Updated to Build 4.1.6.37
remotes/origin/feature/cleanups ef035e9 Added alert dialog
remotes/origin/master 0aa9613 Release 4.1.6.37
so the remotes/* were created by git flow. I only created develop and master manually
but how do I clone all the remotes back to my local drive easily?
I tried
git fetch
but not sure what it did, since if I issue
git branch
I only see on my drive the two main branches.
* develop
master
gmmo@DESKTOP-GIMBJM0 MINGW64 /C/Dogwood (develop)
Is there an easy way to clone all these branches, without re-cloning the entire repo?
thx!
Upvotes: 2
Views: 913
Reputation: 3301
If you want to get a remote branch locally, you need to check it out. When you do
git checkout feature/cleanups
git should be smart enough to recognise it's a remote repository and automatically creates a local copy of the branch that tracks the remote version. If this doesn't work, you probably run an old version of git, and I would advise trying to update. An alternative that works on older versions is
git checkout --track origin/feature/cleanups
You can also work from SourceTree. Find and double-click the branch under Remotes > origin. It creates a popup for checking out a new branch; default values should be OK.
That said, the behaviour you describe is a bit odd. When you clone a local repository, you should get an exact copy, including feature branches. You said you tried to "clone these branches". You clone repositories, not branches. You can clone a copy of a repository getting only one branch with the --single-branch
option (see the docs), but there is limited use for this.
Upvotes: 2