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:
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:
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
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