I'm starting to deploy a few website plugins via git.
I've been through a number of tutorials on the web and all of them recommend creating a bare remote repository on the web server with a post-update hook to checkout into the DocumentRoot directory. I've gotten this all working without too many issues.
Why are we separating the respository from the working directory? What's wrong with just using the DocumentRoot directory as the repository and then using htaccess to prevent public access to any .git content?
Repositories in Git are a snapshot of the folder in which you are working on your project. You can track the progress and changes made to the project by making commits and also revert changes if not satisfactory.
A Git repository tracks and saves the history of all changes made to the files in a Git project. It saves this data in a directory called . git , also known as the repository folder. Git uses a version control system to track all changes made to the project and save them in the repository.
A bare repository is one that contains nothing but the . git folder; in other words, it has the index but lacks the actual working files. A non-bare repository is what you're used to working with, which includes both the git index and the checked out copy of working files.
Git deployment If you want to share changes with others, you run git push . Since only changesets are uploaded or pulled, these operations are very fast. However, many people don't know that they can deploy with Git just as easily.
Actually the security risks inherent in a poorly configured htaccess are a good reason by themselves, but the main reason is that by default, you can't push to the checked-out branch of a non-bare repo. (It can be enabled, but then requires a git reset --hard
to update the work tree, and is no simpler than having a separate deployment directory.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With