News for hackers. Stuff that matters.
Re:Tell HN: HN Replies Data Security Incident by darekkay on Wednesday April 28, 2021 @10:02AM (#26969477)
> have a subdirectory contain the web-accessible files

You can also separate your git repository from the working directory. I have my git repositories at ~/repositories, with a post-receive hook that checks out the working directories at ~/projects and then _actively_ copies only relevant files to ~/html. Basically a "poor man's CI/CD", with the bonus of having to opt-in to publish any files.

Re:Tell HN: HN Replies Data Security Incident by DCoder on Wednesday April 28, 2021 @11:28AM (#26970486)
You can also tell git that the .git dir is completely separated from the working dir:

    alias dogit='GIT_WORK_TREE=/path/to/src/dir GIT_DIR=/path/to/dotgit/dir git'
    dogit pull remote treeish
---

I set this up as a "poor man's version control" on a large client's server back in 2016-ish. I was lost for words when last year I saw my colleagues still using Ctrl-R to rerun that alias line.

Re:Tell HN: HN Replies Data Security Incident by darekkay on Wednesday April 28, 2021 @11:42AM (#26970651)
Yes, that's roughtly what I am doing in my post-receive hook:

    export GIT_DIR=/path/repo
    export GIT_WORK_TREE=/path/working-directory
    git checkout -f