user4561003
user4561003

Reputation:

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.

Upvotes: 0

Views: 97

Answers (1)

SLaks
SLaks

Reputation: 887469

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

Upvotes: 3

Related Questions