Git: Archiving a project within another git project

At hubdoc we have a commercial github account for private repositories. This gives you a fixed number of repositories, meaning that when we exceed that number we have to pay more, or delete some old repositories. Neither is a great solution.

But those old repositories generally aren’t needed any more, but it is nice to keep the history.

So after a bit of googling, here’s what I came up with to copy another repo into another, keeping the history:

git clone git@github.com:/hubdoc/archive
cd archive
git fetch git@github.com:/hubdoc/repo-to-archive.git
GIT_INDEX_FILE=.git/tmp-index git read-tree --prefix=repo-to-archive/ FETCH_HEAD
GIT_INDEX_FILE=.git/tmp-index git checkout-index -a -u
git update-index --add -- `GIT_INDEX_FILE=.git/tmp-index git ls-files`
git commit -m "Merged over repo-to-archive"
git push

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s