Let\'s say I\'ve got a setup that look something like
phd/code/
phd/figures/
phd/thesis/
For historical reasons, these all have their own g
@MiniQuark solution helped me a lot, but unfortunately it doesn't take into account tags which are in source repositories (At least in my case). Below is my improvement to @MiniQuark answer.
First create directory which will contain composed repo and merged repos, create directory for each merged one.
$ mkdir new_phd
$ mkdir new_phd/code
$ mkdir new_phd/figures
$ mkdir new_phd/thesis
Do a pull of each repository and fetch all tags. (Presenting instructions only for code
sub-directory)
$ cd new_phd/code
$ git init
$ git pull ../../original_phd/code master
$ git fetch ../../original_phd/code refs/tags/*:refs/tags/*
(This is improvement to point 2 in MiniQuark answer) Move the content of new_phd/code
to new_phd/code/code
and add code_
prefeix before each tag
$ 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' --tag-name-filter 'sed "s-.*-code_&-"' HEAD
After doing so there will be twice as many tags as it was before doing filter-branch. Old tags remain in repo and new tags with code_
prefix are added.
$ git tag
mytag1
code_mytag1
Remove old tags manually:
$ ls .git/refs/tags/* | grep -v "/code_" | xargs rm
Repeat point 2,3,4 for other subdirectories
Now we have structure of directories as in @MiniQuark anwser point 3.
Do as in point 4 of MiniQuark anwser, but after doing a pull and before removing .git
dir, fetch tags:
$ git fetch catalog refs/tags/*:refs/tags/*
Continue..
This is just another solution. Hope it helps someone, it helped me :)