Work in hardlinked git clones
One of my 500mb git repositories got corrupted and I had to clone from scratch. This time, I cloned to a cache directory. Then I clone again from the cache directory to my real workarea. Takes less than 2 seconds on SSD and hopefully it will save me some time when I want another clone.
Clone the large repo in a cache directory:
git clone git@github.com:destructuring/badonkadonk ~/work/cache/
Created a hardlinked clone, but the straightforward way only fetches one
branch:
git clone ~/work/cache/badonkadonk ~/work/
To fetch all branches, create a mirror and then convert back to a normal
working repository:
cd ~/work/cache
git clone --mirror cache/badonkadonk badonkadonk/.git
Fix up the remotes in the harlinked clone. Deleting the hardlinked
origin takes a while so will just rename it.
cd ~/work/badonkadonk
git remote rename origin hardlinked
git remote add origin git@github.com:destructuring/badonkadonk
git fetch origin
Convert to a working repository and check out a branch:
git config core.bare false
git checkout master
git push -u origin master
Written by Tom, Bom
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#