how to pull theme files out of a DSpace git repository into their own git repository
Nov 21, 02:14 PM
So, my goal with this work is to be able to have a set of DSpace themes in their own repositories on GitHub, so I can then include them in my own DSpace repository as submodules .
Credit where credit is due, I used the suggestions on these pages for inspiration:
stackoverflow:extract-part-of-a-git-repository
airbladesoftware:moving-a-subdirectory-into-a-seperate-git-repository
However, this page is the one I finally selected as my guide:
stackoverflow:detach-subdirectory-into-seperate-git-repository
Here is the process I followed, in order to extract this recent version of the Mirage theme (Note, the following will extract just the Master/HEAD history for the Mirage theme, and will drop all branches and tags… the resulting repository will be useful as an include/subrepository for a project which is following Master, but won’t be useful for an older code base).
git clone git@github.com:hardyoyo/DSpace.git mirage
cd mirage
git remote rm origin #let's avoid inadvertant pushes back to origin, shall we?
git tag -l | xargs git tag -d
git filter-branch --tag-name-filter cat --prune-empty --subdirectory-filter dspace-xmlui/src/main/webapp/themes/Mirage HEAD
git reset --hard
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all
git gc --aggressive --prune=now
This same tactic should work for pulling out any theme from any repository… now just to figure out how to use it. First, let’s put it up somewhere:
- create a bare repo on GitHub (in this example, I’ve called it “mirage”
- enter the following at the root of the extracted repository created in the steps outlined above:
git remote add origin git@github.com:your-github-user-name/mirage.git
git push -u origin master
If you’re curious about how you might make use of this extracted theme, read Git Tools – Submodules (apologies for the odd formatting above, I’m still not quite used to Textile, and I can’t figure out how to get two blocks of code into the same article… argh!)