Is it possible to deploy a website using git push
? I have a hunch it has something to do with using git hooks to perform a git reset --hard
on the server side, but how would I go about accomplishing this?
Git – Deploy a project using Git push
deploymentgitgithookswebserver
Related Topic
- Git – the difference between ‘git pull’ and ‘git fetch’
- Git – How to undo ‘git add’ before commit
- Git – How to undo the most recent local commits in Git
- Git: How to force “git pull” to overwrite local files
- Git – How to create a remote Git branch
- Git – How to delete a Git branch locally and remotely
- Git – How to push a tag to a remote repository using Git
- Git – How to rename a local Git branch
Best Answer
I found this script on this site and it seems to work quite well.
On your local copy, modify your .git/config file and add your web server as a remote:
On the server, replace .git/hooks/post-update with this file (in the answer below)
Add execute access to the file (again, on the server):
Now, just locally push to your web server and it should automatically update the working copy: