tags:

views:

108

answers:

3

Hi,

i'd like to just checkout the files without the .git files and the whole repository. It's because i'd like to manage a website (php & html) with git and i'm looking for an easy way to update the files in the htdocs folder from the repository, without having the repository public. (now it's in the home-dir and is accessed via ssh, but i have to put the new files to htdocs manually.

+1  A: 

Git is much easier than Subversion for this, as the whole repository is held in a single directory. You only need to delete the hidden ".git" folder in the root of the project to create a production-ready copy of your site.

In Linux/OSX this would be:

mkdir dist && cd dist
git checkout http://path/to/your/project.git
rm -rf .git
seanhodges
+1  A: 

You could create a tar archive in a git working directory and copy the tar to the server:

git archive -o foo.tar HEAD
scp foo.tar server:
Sven Marnach
+4  A: 

The git-archive manpage contains the following example:

git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)

Create a tar archive that contains the contents of the latest commit on the current branch, and extract it in the '/var/tmp/junk' directory.

Or you can use low level git-checkout-index, which manpage contains the following example:

Using git checkout-index to "export an entire tree"

The prefix ability basically makes it trivial to use 'git checkout-index' as an "export as tree" function. Just read the desired tree into the index, and do

   $ git checkout-index --prefix=git-export-dir/ -a

git checkout-index will "export" the index into the specified directory.

The final "/" is important. The exported name is literally just prefixed with the specified string.

Or you can try to use --work-tree option to git wrapper, or GIT_WORK_TREE environment variable, e.g. by using "git --work-tree=/somwehere/else checkout -- .".

Jakub Narębski
git-archive is great for this. also, you can also use git archive --remote to build an archive directly from a remote repo (even over git:// protocol iirc) and hence use this as a way to fetch straight from a central point. e.g. `git archive --remote git://git/mindy.git --format tar r3.2.0 | tar tf -` (provided you enable upload-archive in git-daemon config)
araqnid