For production environments i usually use git clone --single-branch to save disk space because I don't want to spend disk space for all branches.
Yesterday I had to upload to production different feature branch from GitHub and as expected, i couldn't find the branch in the "git branch" list. i tried to use "git fetch origin/MyBranch" and "git checkout --track origin/MyBranch" but nothing helped.
The solution for the above was to change the [fetch] configuration in .git/config file from "fetch = +refs/heads/master:refs/remotes/origin/master" to "fetch = +refs/heads/:refs/remotes/origin/" on the [origin] section.
The problem is that after doing that, git fetch fetched (as expected) all the branches to my local drive...
My question is how can I fetch only the branches i need and not all of them after using "git clone --single-branch" and how can i remove now all the unneeded branches from my local drive only.
Thanks
git branch -D <branch>
. Regarding fetching a single branch, the--single-branch
should've worked. – leoOriongit init
and thengit fetch url-to-repo <branch>:refs/remotes/origin/<branch>
– leoOrion