Most mentions of post-receive hooks that I have seen are set up in bare repos. Why is this?
If I only want pushes to the master
branch to get deployed to my public_html
folder, and all of my pushes are going to a bare repo with a post-receive hook, doesn't that mean that all of my non master
pushes are not backed up on the server anywhere?
For example, say I have the setup mentioned above where I have a bare repo set up on my server with a hook that deploys to my live site folder. I go into development of a new feature for a month constantly pushing to a feature branch. Then one day (having not pushed to master yet) my local machine crashes/burns. All of my work in that feature branch is seemingly lost. What do people do in this scenario? Have another repo that a hook sends all pushes to?
Assuming your server is not your local machine, your server didn't crash, and you did push your development branch to your server, your development branch will still be on your server. It won't be in a human-readable format, but you can simply clone again from the repository on your server, and retrieve all branches, even the ones that didn't get deployed automatically.
This is not really related to bare or non-bare repos. The reason post-receive hooks are typically set up in bare repos is simply because typically only bare repos receive content from clients. It's possible to set up a non-bare repository to receive content from clients, but it's more trouble than it's generally worth, as it causes problems if the currently checked out branch receives an update.