Thursday, December 10, 2009

Merging Git Repositories

There's a bunch of ways of merging git repositories. Here's the one that I find easiest. Say I've developed some test features in directory/repository A that I want to start to use in directory/repository B


First I package everything into a temporary directory inside A in preparation for moving

cd /path/to/A     
mkdir A_merge     
git mv * A_merge     
git mv .gitignore A_merge/.gitignore
git commit -m"Preparation for merging A into B"


Then I create a branch in B for merging into
cd /path/to/B
git checkout -b merge_A_into_B
Next get the stuff from A's master branch and merge with the current branch.
git fetch file:///path/to/A 'refs/heads/*:refs/remotes/A/*'
git merge A/master
All the stuff that you need should now be in /path/to/B/A_merge.
Move this directory and its contents to whereever you want and commit.

No comments:

Post a Comment