intentó mover el repositorio de git a otro repositorio, falló

Tengo dos repositorios de git:

git_repo_A: https://github.com/gnychis/coexisyst
git_repo_B: https://github.com/gnychis/android-wireless-monitor

I want to move everything in git_repo_A in to a subdirectory in git_repo_B called: application. I want to preserve all commits and file history.

So, after the move, git_repo_A would look like this:

git_repo_A/application/git_repo_B

I found this website that described basically the exact operation that I wanted: http://www.nomachetejuggling.com/2011/09/12/moving-one-git-repo-into-another-as-subdirectory/

So I gave it a shot, but I don't think it did what I wanted it to.

What looks like ended up happening is two .* files in the main directory got added to git_repo_A/ ... and then everything I wanted to show up as git_repo_A/application ended up as a delete operation. Here are the relevant two operations which got moved in to git_repo_A:

https://github.com/gnychis/android-wireless-monitor/commit/23e6639221733158d197bf7c29df8998e8a5c2ef

https://github.com/gnychis/android-wireless-monitor/commit/455ba86a80d8300b16bdd9527c444ebad78f7a9a

I followed the instructions exactly, but that doesn't mean the instructions were correct. I think it is odd they moved the entire directory without re-adding it. However, I fear if you move it and then re-add it, it doesn't preserve the file history.

I am the only person who uses these repositories. So it would also be good to hard reset everything that occurred on March 9 and start over: https://github.com/gnychis/android-wireless-monitor/commits/

preguntado el 09 de marzo de 12 a las 15:03

So you don't want repo A to exist on it's own any more? If you want it to still live, you can submodule it into repo B. -

Hmmm I don't see the difference? Once I move it in to repo B I don't plan on making changes in repo A anymore. All changes will be in repo B -

1 Respuestas

I've done something very similar to this before. It's almost identical to the process listed in your link, except this allows you to clean things up before committing your merge.

1) In RepoB (the one you want to keep) add a remote to RepoA
git remote add RepoA <path_to_repo>

2) Fetch RepoA history into RepoB
git fetch RepoA

3) Merge your relevant branches (assuming you're on RepoB/master)
git merge RepoA/master

4) Move the RepoA files to the appropriate subfolder and commit
git add .
git commit -a


If you haven't done anything to your RepoB since following the instructions you posted you can do this: git reset HEAD~
Now move any files and clean up what you need.
git add .
git commit -a


As far as moving files and keeping history is concerned, git will track renames for a small number of files by default, since doing so is slow. If you want it to track everything you can use the following command
git config --global diff.renamelimit 0

respondido 09 mar '12, 21:03

so, I tried this method but I'm not sure it preserved the history of my files. Here is an example file: github.com/gnychis/android-wireless-monitor/commits/master/… the only history I see with it is the merge. - gnychis

Did you set the renamelimit before committing the merge? - Robert Dusek

eek, i didn't, let me try that again - gnychis

no luck after changing the rename limit either :\ github.com/gnychis/android-wireless-monitor/commits/master/… This shows my bash history of my attempt: pastebin.com/P3PL3LNR - gnychis

although, I do see 2 parents from the commit: github.com/gnychis/android-wireless-monitor/commit/… - gnychis

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.