简体   繁体   中英

How do I clone an entire repository into a branch other than master?

Update

I think my question has a mistake but @SLaks answer helped me realize that.


Based on the research I did, there are a lot of solutions to cloning from branches other than master.

However, I want to clone the branch master ( of the source repo ), but not into the branch master ( of the current repository I am working on). I want to clone the source repo into a branch called 'previously' which will house all work done previously in the previous repo; I want to leave master clean with only files pertinent to the current repo.

More context

Whenever I use the clone command and the url of the source repo, I end up filling the master branch of the current repo with the files from the previous repo. Instead, I want the branch previously to be filled with those files.

Cloning does not affect any current repo in any way; it creates a new repo.

You want to fetch the other repo into yours, then make a branch pointing to its HEAD:

git fetch <remote URL>
git branch previous FETCH_HEAD

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM