Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I acquire a "cleansed" Git repository?

Tags:

git

I can't seem to find the answer to this seemingly simple question, anywhere: How do you acquire a clean copy of a code repository once you "release" it? For instance, say I'm at a place in my Git repository where I want to release a copy. How do I copy it without all the Gitiness? I don't want any hidden Git directories, etc. I want a clean deliverable product. Ideas? I'm working with RoR, btw.

Best

like image 557
humble_coder Avatar asked Jan 26 '26 21:01

humble_coder


2 Answers

You may want git archive, e.g.

git archive --format=tar -o /path/to/archive.tar master

Note that the above gets you a whole tree. If you want, can pare it down to only specific directories, including going down multiple "levels":

git archive --format=tar -o /path/to/archive.tar master somedir/ another/dir/
like image 112
Nicholas Knight Avatar answered Jan 29 '26 12:01

Nicholas Knight


In your git directory, there's really only one directory that is "gitty," and that is .git.

Here's what I propose, you check out your release branch and copy it elsewhere, except for the .git folder. This packs your working directory into a tarball:

$tar --exclude .git -cjf release.tar.bz2 * 
like image 30
nes1983 Avatar answered Jan 29 '26 11:01

nes1983



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!