tags:

views:

116

answers:

4

I want to clone a GIT repo and NOT end up with a .git directory. In other words I just want the files. Is there a way to do this?

git clone --no-checkout did the exact opposite of what I want (gave me just the .git directory).

I am trying to do that for a remote repo, not a local one, meaning this is not a duplicate of "How to do a “git export” (like “svn export”)" (even though the solution might end up being the same).

A: 

Why not perform a clone and then delete the .git directory so that you just have a bare working copy?

Edit: Or in fact why use clone at all? It's a bit confusing when you say that you want a git repo but without a .git directory. If you mean that you just want a copy of some state of the tree then why not do cp -R in the shell instead of the git clone and then delete the .git afterwards.

Amoss
Thanks for that. The files are in a git repo. I was hoping to be able to direct Mac users to get a copy of the repo in one line, without it becoming a GIT repo.
Yar
You shouldn't have people directly getting code from the repo if they can't use it (ie don't have the Git repository).
mathepic
@mathepic: why not? it might be more helpful if you answered with an alternative
Amoss
@Amoss Releasing a tarball so that people aren't constantly grabbing the latest code?
mathepic
@mathepic: and to release a tarball you need a way of getting a clean working copy out of the repository - which is exactly the question that was posed.
Amoss
@Amoss it sounds like he wants to have the user download it with git then delete the .git repository. In any case, this is the wrong thing to do anyway. For example, I wouldn't check ./configure in to the source control because its autogenerated with configure.ac, but you want to distribute it with ./configure.
mathepic
+4  A: 

you can create a shallow clone to only get the last few revisions:

 git clone --depth 1 git://url

then either simply delete the .git directory or use git archive to export your tree.

knittl
A: 

It sounds like you just want a copy of the source code. If so why not just copy the directory and exclude the .git directory from the copy?

JaredPar
That's what I'm asking: how to do that with git... I can already tell that there's no built-in way to do it from the answers that I'm getting, though. Thanks anyway!
Yar
+4  A: 

The git command that would be the closest from what you are looking for would by git archive.
See backing up project which uses git: it will include in an archive all files (including submodules if you are using the git-archive-all script)

You can then use that archive anywhere, giving you back only files, no .git directory.

VonC
Interesting possibility, thanks VonC.
Yar