3 ms·
Some of the other commenters suggest adding git-dir and work-tree to the git commands, but there's a better solution: use the --separate-git-dir option when clo
by quicksilver03 11y ago
Some of the other commenters suggest adding git-dir and work-tree to the git commands, but there's a better solution: use the --separate-git-dir option when cloning the repository.
For example:
git clone --separate-git-dir=<repo dir> <remote url> <working copy>
where <repo dir> is outside of any directory served by the web server and <working copy> is the htdocs root.
This option makes <working copy>/.git a file whose content is:
gitdir: <repo dir>
The advantage is that all git commands work as usual, without the need to set git-dir and work-tree, and that there's nothing special to add to the web server configuration.
- raverbashing 11y agoI disagree It may be possible that gitdir is still accessible through a misconfiguration or security issue (and you're giving them exactly where to look) Production servers have no business having the .git directory anywhere.
- quicksilver03 11y ago> Production servers have no business having the .git directory anywhere. I agree with you in principle, but in practice this is not always possible, there are situations when having a git checkout in production is better than nothing. I've seen WordPress sites where a semi-technical administrator updates plugins and themes directly in production: with that git checkout I would at least be able to track the changes and pull them in a dev or staging environment. This could be the first step to a saner deployment workflow for those sites, where production gets changes that have been tested and validated elsewhere.