Reputation: 19
I have a git repo (local) and I need to un-git it so that each commit is stored in a folder and there is no sign of git. So it should result in folders of my branches and inside these folders folders representing each commit.
Is this possible?
Upvotes: 1
Views: 1353
Reputation: 133712
Well, something like this:
n=0
git rev-list --reverse HEAD | while read rev; do
n=$(expr $n + 1)
dir="$n-$rev"
mkdir "$dir"
git archive --format=tar "$rev" | ( cd $dir && tar xvf - )
done
This will put the revisions into folders numbered "1-hash", "2-hash" etc. (change the formula to calculate dir as appropriate).
Also this only works for "HEAD"... it's hard to come up with a numbering scheme if you need all the branches, and hard to know what to call the directories otherwise. Although you could simply use git rev-list --branches
and then calculate dir as $(git name-rev "$rev")
Ideally you would be able to extract the files using hard links to represent identical content, but that would be quite a bit more work!
Upvotes: 4