GIT: HOW TO PULL JUST A DIRECTORY WITH NO 'GIT' STUFF IN IT
Overview
If you are working in a web-tree and you want to pull your website out of git, but you don't want all the "git" detail, the easiest way is to pull just a directory from the remote git repository and then replace your webtree with it as follows:
In your $HOME directory, **NOT** in your webtree, pull the webserver public root directory as follows (this is from a web-tree already commited to the repository):
ssh <user>@cvs.company.com "cd /<git project directory> && git archive --format=tar main public" | tar -x -
This says:
- ssh to remote repository as you
- switch into the repository directory where your git project is stored
- get all of the files out of the public directory and return them in a tar stream
- then outside of the ssh session it pipes them back to tar to be written locally into the $CWD (current working directory)
- NODE... if you are fetching a directory and not a file, it will fetch the directory name and put the files under it
- for example "public" will make the subdirectory "public" and put the subsequent files under it.
It doesn't copy any of the git data, or do a checkout, etc. it only copies the files into your directory.