Domanda

I have a branch of a repository on github I am trying to clone. i can clone the main repository at the url https://github.com/pmyusername/myrepository (not actual link since the data is private). However, I cannot clone the branch located at https://github.com/myusername/myrepository/tree/branchname . To clone the repository, I simply needed to run:

git clone https://github.com/myusername/myrepository

but if i try to run:

https://github.com/myusername/myrepository/tree/branchname

I receive the error:

fatal: repository 'https://github.com/myusername/myrepository/tree/branchname' not found

but I know it exists because i am copying and pasting it from the url. The problem might have to do with the fact that I pay to keep it private, but i don't think so. Does anyone have any ideas?

È stato utile?

Soluzione

I'll try to aggregate all the comments into a succinct response...
Step 1: git clone https://github.com/myusername/myrepository
Step 2: git fetch
Step 3: git checkout -b desired_branch # add origin/desired_branch to end of command line to set up remote tracking

UPDATE:
Just did a quick experiment with daniellarsson's suggestion, and it appears to work:
i:work> git clone -b metro git@github.com:user/project.git
i:work> cd project
I:\work\project> git branch -a
* metro
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/metro

Altri suggerimenti

If you use a UI like GitEx, you can mention the branch you want to clone in the dialog box the appears. This would clone the repo with the branch checked out automatically.

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top