开发者

"Unarchive" a git repository

I have a git repo (loc开发者_JAVA百科al) 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?


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜