Reputation: 5975
We have a repo in git where the project is contained in a folder called Project. We'd like to be able to release the code to a production server, by cloning the repo, without including the "Project" folder, but with everything below it. Is this possible? The destination directory name is /var/www, which is unrelated to anything in the project. Unfortunately I can't just do a symbolic link because of the nature of our hosting provider (which we'll change soon).
Upvotes: 3
Views: 1801
Reputation: 11949
My answer take the assumption that you have a git repository whose content is the following:
/.gitignore
/Project
/Project/index.php
/ProjectB
/ProjectB/pom.xml
If you don't need history at all in that copy of your repository, there is the git archive
command which can do what you want except its output its data in tar
or zip
format:
git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
[-o <file> | --output=<file>] [--worktree-attributes]
[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
[<path>…]
Like:
git archive --format=zip [email protected] master -- Project | unzip
However, the git clone command does not accept a repository path, and I think it's not really git like to export only a tree view of some branch. You would probably need a submodule making Project an independent git repository, or like the git archive
example, get only what you want but without versioning (which can be questionable on a production server).
Instead, you can do that:
/opt/foobar
./opt/foobar/Project
in /var/www
.Or reference the /opt/foobar/Project
in your apache configuration (to avoid the symlink) instead of plain /var/www
.
Upvotes: 2