Roman A. Taycher
Roman A. Taycher

Reputation: 19487

How do I split a git repository(by branch)

I started with a piece of code which got split into two small programs each in a different branch.

They share a lot of similarities but I'd like to split them into 2 repos so I can work on both at the same time in an easier fashion. It's annoying to have to commit a change(and get rid of/commit unimortant changes (such as gitignore and makefile flags) before switching context before switching.

It's a pretty simple linear one person history except for that early split and a few unneeded stashes.
What's the best way to accomplish it?

Upvotes: 2

Views: 332

Answers (2)

sehe
sehe

Reputation: 393084

Even simpler

mkdir program1
cd program1
git init
git pull ../origrepo smallprogram1

rinse, repeat

If you have stuff in a branch history that shouldn't be in that history any more, see git-filter-branch (e.g. --index-filter 'git rm unwanted-bits') and you're good to go

Don't forget to vacuum on your way out (git gc --prune=... or git repack)

Upvotes: 1

Arafangion
Arafangion

Reputation: 11910

The simplest way is to just clone the repository, and possibly, delete the unneeded branch in the cloned repository.

Upvotes: 5

Related Questions