Fernando Montoya
Fernando Montoya

Reputation: 2644

Git: Copy existing repo to new branch

I need to copy an existing git repository to a new branch on an existing git repository I tried

git branch new_branch
git checkout new_branch
git remote add project url/to/existing/repo
git fetch

But it doesn't work, I need to preserve the commit history :)

Upvotes: 0

Views: 302

Answers (1)

jthill
jthill

Reputation: 60555

So, you just want to fetch everything from your repo? Do that.

git remote add existing url/to/existing/repo
git fetch existing

and then add tracking branches for anything you care about.

Upvotes: 1

Related Questions