git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Right way to import a repo
@ 2012-12-21 16:11 Florian Lindner
  2012-12-22 17:57 ` Michael J Gruber
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Lindner @ 2012-12-21 16:11 UTC (permalink / raw)
  To: git

Hello,

I have two repositories. tools and flof. I want to merge flof into tools (and 
flof will be deleted after that) while keeping history intact. Of course I've 
googled that and found a number of different solution which all seem to be 
pretty komplex, so I just tried it myself. It seems to work.... are there any 
problems with my approach?

~/software/tools.test (git)-[master] % git remote add fl ~/flof

~/software/tools.test (git)-[master] % git fetch fl
warning: no common commits
remote: Counting objects: 475, done.
remote: Compressing objects: 100% (460/460), done.
remote: Total 475 (delta 251), reused 0 (delta 0)
Receiving objects: 100% (475/475), 190.40 KiB, done.
Resolving deltas: 100% (251/251), done.
From /home/florian/flof
 * [new branch]      master     -> fl/master
 * [new branch]      v2-rewrite -> fl/v2-rewrite

/software/tools.test (git)-[master] % git checkout -b import fl/master
Branch import set up to track remote branch master from fl.
Switched to a new branch 'import'

Doing some mkdir und git mv for reorganisation.

~/software/tools.test/flof (git)-[import] % git commit -m "Reorganize flof."
[import a00ab54] Reorganize flof.
 152 files changed, 0 insertions(+), 0 deletions(-)
 rename {doc => flof/doc}/common.rst (100%)
 rename {doc => flof/doc}/conf.py (100%)
 [...]

~/software/tools.test/flof (git)-[import] % git checkout master
Switched to branch 'master'

~/software/tools.test (git)-[master] % git merge import
Auto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignore
Automatic merge failed; fix conflicts and then commit the result.

Resolving the conflict.

~/software/tools.test (git)-[master|merge] % git add .gitignore

~/software/tools.test (git)-[master|merge] % git commit -m "Merged flof."
[master b8c85be] Merged flof.

~/software/tools.test (git)-[master] % git remote rm fl

Are thery any problems with this procedure? The history seems to intact. I'm 
quite unsure since still being a git beginner. 

Thanks,

Florian

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Right way to import a repo
  2012-12-21 16:11 Right way to import a repo Florian Lindner
@ 2012-12-22 17:57 ` Michael J Gruber
  0 siblings, 0 replies; 2+ messages in thread
From: Michael J Gruber @ 2012-12-22 17:57 UTC (permalink / raw)
  To: Florian Lindner; +Cc: git

Florian Lindner venit, vidit, dixit 21.12.2012 17:11:
> Hello,
> 
> I have two repositories. tools and flof. I want to merge flof into tools (and 
> flof will be deleted after that) while keeping history intact. Of course I've 
> googled that and found a number of different solution which all seem to be 
> pretty komplex, so I just tried it myself. It seems to work.... are there any 
> problems with my approach?
> 
> ~/software/tools.test (git)-[master] % git remote add fl ~/flof
> 
> ~/software/tools.test (git)-[master] % git fetch fl
> warning: no common commits
> remote: Counting objects: 475, done.
> remote: Compressing objects: 100% (460/460), done.
> remote: Total 475 (delta 251), reused 0 (delta 0)
> Receiving objects: 100% (475/475), 190.40 KiB, done.
> Resolving deltas: 100% (251/251), done.
> From /home/florian/flof
>  * [new branch]      master     -> fl/master
>  * [new branch]      v2-rewrite -> fl/v2-rewrite
> 

Two disjoint histories, nothing wrong with that.

> /software/tools.test (git)-[master] % git checkout -b import fl/master
> Branch import set up to track remote branch master from fl.
> Switched to a new branch 'import'
> 
> Doing some mkdir und git mv for reorganisation.

Here avoid possible problems from both projects using the same root (in
the filesystem/tree sense).

> ~/software/tools.test/flof (git)-[import] % git commit -m "Reorganize flof."
> [import a00ab54] Reorganize flof.
>  152 files changed, 0 insertions(+), 0 deletions(-)
>  rename {doc => flof/doc}/common.rst (100%)
>  rename {doc => flof/doc}/conf.py (100%)
>  [...]
> 
> ~/software/tools.test/flof (git)-[import] % git checkout master
> Switched to branch 'master'
> 
> ~/software/tools.test (git)-[master] % git merge import
> Auto-merging .gitignore
> CONFLICT (add/add): Merge conflict in .gitignore
> Automatic merge failed; fix conflicts and then commit the result.
> 
> Resolving the conflict.
> 
> ~/software/tools.test (git)-[master|merge] % git add .gitignore
> 
> ~/software/tools.test (git)-[master|merge] % git commit -m "Merged flof."
> [master b8c85be] Merged flof.
> 
> ~/software/tools.test (git)-[master] % git remote rm fl
> 
> Are thery any problems with this procedure? The history seems to intact. I'm 
> quite unsure since still being a git beginner. 

It works in the sense that git follows the renames (moves) you had to do
prior to the merge.

Other tools like git-subtree do that history implanting in one step, by
putting the added project into a subtree (rewriting the history). That
way you don't have reorg commits in the history.

Michael

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-22 17:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-21 16:11 Right way to import a repo Florian Lindner
2012-12-22 17:57 ` Michael J Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).