10

I am using the following steps to duplicate all branches to the new-repository.

git clone --bare https://github.com/exampleuser/old-repository.git # Make a bare clone of the repository cd old-repository.git git push --mirror https://github.com/exampleuser/new-repository.git # Mirror-push to the new repository 

Now, I have added two new branches in old-repository.git and want to move only those 2 branches to new-repository.git

What git commands are required to perform it?

3
  • I don't have an exact answer, but what is your motivation for wanting to move only two branches? Commented Mar 15, 2018 at 2:25
  • I am moving from old-repo to new-repo. I have already moved all the branches to new-repo except 2 newly created branches in old-repo Commented Mar 15, 2018 at 2:27
  • Perhaps you can try just pushing those new branches to the other repository, see here. Commented Mar 15, 2018 at 2:30

3 Answers 3

21

You can add new_repo as a remote for old repo: this is more convenient for pushing:

cd old_repo git remote add new /path/to/new/repo git push new newBranch1 git push new newBranch2 
Sign up to request clarification or add additional context in comments.

Comments

6

Clone old branch

git clone --single-branch --branch branch_name github_repo_url 

Tell git where your repo is:

git remote add mine your_repo_url 

Then, push the branch to your repo with:

git push -u mine 

1 Comment

You don't have to clone your repo, you can directly point to the new one from the old one.
0

cd old_repo
git remote add new <New_git_repo_cloning_link>
git push new branchName

2 Comments

Isn't this essentially what I put in my own answer five years ago?
Duplicate of already accepted answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.