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

Tengo dos repositorios de git:


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:


I found this website that described basically the exact operation that I wanted:

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:

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:

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:… 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 :\… This shows my bash history of my attempt: - gnychis

although, I do see 2 parents from the commit:… - gnychis

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