Skip to content

Instantly share code, notes, and snippets.

@areina
Created February 8, 2012 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save areina/1768178 to your computer and use it in GitHub Desktop.
Save areina/1768178 to your computer and use it in GitHub Desktop.
Pasos que s'han fet per unificar els repos d'ubiquo.
* Unificar els repos (tret de http://stackoverflow.com/questions/277029/combining-multiple-git-repositories)
Here's a solution I gave here:
First do a complete backup of your phd directory: I don't want to be held responsible for your losing years of hard work! ;-)
$ cp -r phd phd-backup
Move the content of phd/code to phd/code/code, and fix the history so that it looks like it has always been there (this uses git's filter-branch command):
$ cd phd/code
$ git filter-branch --index-filter \
'git ls-files -s | sed "s-\t-&code/-" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
Same for the content of phd/figures and phd/thesis (just replace code with figures and thesis).
Now your directory structure should look like this:
phd
|_code
| |_.git
| |_code
| |_(your code...)
|_figures
| |_.git
| |_figures
| |_(your figures...)
|_thesis
|_.git
|_thesis
|_(your thesis...)
Then create a git repository in the root directory, pull everything into it and remove the old repositories:
$ cd phd
$ git init
$ git pull code
$ rm -rf code/code
$ rm -rf code/.git
$ git pull figures
$ rm -rf figures/figures
$ rm -rf figures/.git
$ git pull thesis
$ rm -rf thesis/thesis
$ rm -rf thesis/.git
Finally, you should now have what you wanted:
phd
|_.git
|_code
| |_(your code...)
|_figures
| |_(your figures...)
|_thesis
|_(your thesis...)
One nice side to this procedure is that it will leave non-versioned files and directories in place.
Hope this helps.
Just one word of warning though: if your code directory already has a code subdirectory or file, things might go very wrong (same for figures and thesis of course). If that's the case, just rename that directory or file before going through this whole procedure:
$ cd phd/code
$ git mv code code-repository-migration
$ git commit -m "preparing the code directory for migration"
And when the procedure is finished, add this final step:
$ cd phd
$ git mv code/code-repository-migration code/code
$ git commit -m "final step for code directory migration"
Of course, if the code subdirectory or file is not versioned, just use mv instead of git mv, and forget about the git commits.
* Per a poder tenir-lo en ordre, generar els patches de tot i aplicar-ho en un projecte nou. D'aquesta forma queda tot ordenat per AUTHOR_DATE.
* Canviar la data del commit (es pot fer de tot el repo o passar-li revisions)
git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"' 5ba6a69..HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment