When cloning a branch : Remote branch not found in upstream origin
This question already has an answer here:
branch-99
does not exist on the remote repository. You probably misspelled the branch name or the repository.
To check which branches exist, clone the repository normally and list the remote branches.
git clone git@github.com:Christoffer/admin.git
git branch -r
Alternatively, to avoid having to clone the whole repository just to check for the branches you can use ls-remotes, but you have to init the repository and add the remote manually. Only do this if the repository is huge and you don't intent to use it.
git init admin
cd admin
git remote add origin git@github.com:Christoffer/admin.git
git ls-remote --heads origin
To be clear, git clone -b branch-99 git@github.com:Christoffer/admin.git
clones the entire repository. It just checks out branch-99
rather than master
. It's the same as...
git clone git@github.com:Christoffer/admin.git
git checkout branch-99
That bit of syntax sugar isn't worth the bother. I guess it might save you a tiny bit of time not having to checkout master.
If you want to clone just the history of one branch to save some network and disk space use --single-branch
.
git clone --single-branch -b branch-99 git@github.com:Christoffer/admin.git
However it's usually not worth the trouble. Git is very disk and network efficient. And the whole history of that branch has to be cloned which usually includes most of the repository anyway.
git clone git@github.com:Christoffer/admin.git
git checkout branch-99
链接地址: http://www.djcxy.com/p/90436.html
上一篇: 仅克隆Github上的特定分支?
下一篇: 克隆分支时:在上游原点找不到远程分支