Created
September 6, 2008 02:04
-
-
Save tekkub/9069 to your computer and use it in GitHub Desktop.
Using the subtree merge to join two repos, but maintain their history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For more details: | |
| http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html | |
| gitk --all output: | |
| http://www.flickr.com/photos/26681170@N03/2831381183/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Tekkub@KAKU: ~/Documents/github]$ mkdir testA | |
| [Tekkub@KAKU: ~/Documents/github]$ cd testA | |
| [Tekkub@KAKU: ~/Documents/github/testA]$ git init | |
| Initialized empty Git repository in c:/Users/Tekkub/Documents/github/testA/.git/ | |
| [Tekkub@KAKU: ~/Documents/github/testA master]$ echo "This is repo A" > README_A | |
| [Tekkub@KAKU: ~/Documents/github/testA master]$ git add README_A | |
| [Tekkub@KAKU: ~/Documents/github/testA master]$ git commit -m "First commit to repo A" | |
| Created initial commit e3b4372: First commit to repo A | |
| 1 files changed, 1 insertions(+), 0 deletions(-) | |
| create mode 100644 README_A | |
| [Tekkub@KAKU: ~/Documents/github/testA master]$ cd .. | |
| [Tekkub@KAKU: ~/Documents/github]$ mkdir testB | |
| [Tekkub@KAKU: ~/Documents/github]$ cd testB | |
| [Tekkub@KAKU: ~/Documents/github/testB]$ git init | |
| Initialized empty Git repository in c:/Users/Tekkub/Documents/github/testB/.git/ | |
| [Tekkub@KAKU: ~/Documents/github/testB master]$ echo "This is repo B" > README_B | |
| [Tekkub@KAKU: ~/Documents/github/testB master]$ git add README_B | |
| [Tekkub@KAKU: ~/Documents/github/testB master]$ git commit -m "First commit to repo B" | |
| Created initial commit ab1b560: First commit to repo B | |
| 1 files changed, 1 insertions(+), 0 deletions(-) | |
| create mode 100644 README_B | |
| [Tekkub@KAKU: ~/Documents/github/testB master]$ cd .. | |
| [Tekkub@KAKU: ~/Documents/github]$ mkdir testAB | |
| [Tekkub@KAKU: ~/Documents/github]$ cd testAB | |
| [Tekkub@KAKU: ~/Documents/github/testAB]$ git init | |
| Initialized empty Git repository in c:/Users/Tekkub/Documents/github/testAB/.git/ | |
| [Tekkub@KAKU: ~/Documents/github/testAB master]$ echo "This is repo AB" > README_AB | |
| [Tekkub@KAKU: ~/Documents/github/testAB master]$ git add README_AB | |
| [Tekkub@KAKU: ~/Documents/github/testAB master]$ git commit -m "First commit to repo AB" | |
| Created initial commit a8b2b79: First commit to repo AB | |
| 1 files changed, 1 insertions(+), 0 deletions(-) | |
| create mode 100644 README_AB | |
| [Tekkub@KAKU: ~/Documents/github/testAB master]$ git remote add -f repoA ../testA | |
| Updating repoA | |
| warning: no common commits | |
| remote: Counting objects: 3, done. | |
| remote: Total 3 (delta 0), reused 0 (delta 0) | |
| Unpacking objects: 100% (3/3), done. | |
| From ../testA | |
| * [new branch] master -> repoA/master | |
| [Tekkub@KAKU: ~/Documents/github/testAB master]$ git merge -s ours --no-commit repoA/master | |
| Automatic merge went well; stopped before committing as requested | |
| [Tekkub@KAKU: ~/Documents/github/testAB master|MERGING]$ git read-tree --prefix=dirA/ -u repoA/master | |
| [Tekkub@KAKU: ~/Documents/github/testAB master|MERGING]$ git commit -m "Merging repoA into dirA" | |
| Created commit 0a29019: Merging repoA into dirA | |
| [Tekkub@KAKU: ~/Documents/github/testAB master]$ git remote add -f repoB ../testB | |
| Updating repoB | |
| warning: no common commits | |
| remote: Counting objects: 3, done. | |
| remote: Total 3 (delta 0), reused 0 (delta 0) | |
| Unpacking objects: 100% (3/3), done. | |
| From ../testB | |
| * [new branch] master -> repoB/master | |
| [Tekkub@KAKU: ~/Documents/github/testAB master]$ git merge -s ours --no-commit repoB/master | |
| Automatic merge went well; stopped before committing as requested | |
| [Tekkub@KAKU: ~/Documents/github/testAB master|MERGING]$ git read-tree --prefix=dirB/ -u repoB/master | |
| [Tekkub@KAKU: ~/Documents/github/testAB master|MERGING]$ git commit -m "Merging repoB into dirB" | |
| Created commit f787b47: Merging repoB into dirB | |
| [Tekkub@KAKU: ~/Documents/github/testAB master]$ ls -R | |
| .: | |
| README_AB dirA dirB | |
| ./dirA: | |
| README_A | |
| ./dirB: | |
| README_B | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment