Jul 22, 2009

How to merge two independent git repositories

I have two independent repositories (A and B) and would like to merge one repo. (B) into another one (A) with keeping the whole history of both. What do to?
With git it appeared to be a very easy task.

cd A
git remote add test ../B && git fetch test
git merge test/master
git push (if you use a remote repo.)

That's it.

You can also merge a subdir of one repo. into another. But to do so you need to use git filter-branch.

I love git! ;)

16 comments:

masha said...

Thanks, this was exactly what I was looking for.

Dmitry said...

Thank you, was really useful! :)

Anar Manafov said...

you are welcome ;)
Git is awesome!

Anonymous said...

Thank you. I am little new to git and was looking for this feature for one of my projects. Your post was very very helpful.

Anar Manafov said...

;) You are welcome!

Anonymous said...

You just saved me some hours of my life. Thanks.

Anar Manafov said...

;) Thanks for the comment!

me said...

Awsome, this made my day... I spent 30 minutes reading complicated ways to do this and I had it done this way in 15 minutes...

Good work!

redhot said...

Thanks! Your blog lays this out very simply. For folks who want to meld two git repos that involves pruning and grafting, this blog gives a run book-

http://www.simplicidade.org/notes/archives/2009/04/merging_two_unr.html

Gordon Barrs said...

+1 for what me said. Thanks for taking the time to post.

Anonymous said...

thanks for share.

Anonymous said...

you are the man. :)

oakleyses said...

louboutin pas cher, nike free, polo ralph lauren outlet online, louis vuitton, polo outlet, nike air max, longchamp pas cher, jordan shoes, ray ban sunglasses, gucci handbags, tiffany and co, jordan pas cher, cheap oakley sunglasses, louis vuitton outlet, oakley sunglasses, christian louboutin uk, nike free run, sac longchamp pas cher, nike air max, oakley sunglasses, longchamp outlet, prada outlet, kate spade outlet, longchamp outlet, louis vuitton, oakley sunglasses wholesale, polo ralph lauren, longchamp outlet, christian louboutin outlet, chanel handbags, louis vuitton outlet, tiffany jewelry, michael kors pas cher, replica watches, replica watches, ray ban sunglasses, ugg boots, burberry pas cher, tory burch outlet, nike roshe, oakley sunglasses, louis vuitton outlet, ray ban sunglasses, prada handbags, ugg boots, nike outlet, christian louboutin shoes, uggs on sale, christian louboutin

oakleyses said...

guess pas cher, north face, lululemon canada, michael kors, michael kors outlet online, true religion outlet, oakley pas cher, nike free uk, michael kors outlet, abercrombie and fitch uk, hollister uk, true religion outlet, hollister pas cher, ray ban pas cher, polo lacoste, north face uk, michael kors outlet online, coach outlet store online, ray ban uk, mulberry uk, burberry handbags, michael kors outlet, hogan outlet, nike blazer pas cher, nike air max, nike air max uk, true religion outlet, uggs outlet, coach outlet, nike air force, nike air max uk, sac hermes, uggs outlet, michael kors outlet, michael kors, michael kors outlet online, nike roshe run uk, vans pas cher, true religion jeans, replica handbags, ralph lauren uk, sac vanessa bruno, burberry outlet, nike tn, coach purses, new balance, michael kors outlet online, kate spade, timberland pas cher

oakleyses said...

hermes belt, hollister, lancel, abercrombie and fitch, chi flat iron, instyler, north face outlet, louboutin, asics running shoes, nfl jerseys, ferragamo shoes, new balance shoes, mont blanc pens, vans outlet, celine handbags, hollister clothing, mcm handbags, mac cosmetics, beats by dre, giuseppe zanotti outlet, converse outlet, nike air max, longchamp uk, oakley, reebok outlet, bottega veneta, nike air max, timberland boots, insanity workout, nike trainers uk, gucci, lululemon, baseball bats, soccer shoes, soccer jerseys, north face outlet, valentino shoes, wedding dresses, hollister, nike roshe run, vans, ray ban, babyliss, jimmy choo outlet, nike huaraches, p90x workout, ghd hair, ralph lauren, herve leger, iphone cases

oakleyses said...

ugg,uggs,uggs canada, barbour uk, moncler outlet, coach outlet, ugg,ugg australia,ugg italia, moncler, thomas sabo, canada goose, moncler outlet, links of london, canada goose outlet, juicy couture outlet, moncler uk, pandora jewelry, montre pas cher, marc jacobs, replica watches, louis vuitton, moncler, canada goose jackets, swarovski, pandora charms, canada goose outlet, toms shoes, moncler, swarovski crystal, doudoune moncler, louis vuitton, moncler, pandora jewelry, ugg, barbour, louis vuitton, hollister, canada goose outlet, karen millen uk, ugg pas cher, supra shoes, canada goose, juicy couture outlet, louis vuitton, wedding dresses, pandora uk, canada goose, ugg uk, canada goose uk, louis vuitton