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?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- WebService 启动调试后,能成功调用函数,但断点进不去任何方法
- Override env values defined in container spec
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
Using the post-update file below:
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 file 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:
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:
In essence all you need to do are the following:
I have those lines in my application as an executable called
deploy
.so when I want to do a deploy I type
./deploy myserver mybranch
.My take on Christians solution.
Sounds like you should have two copies on your server. A bare copy, that you can push/pull from, which your would push your changes when you're done, and then you would clone this into you web directory and set up a cronjob to update git pull from your web directory every day or so.
I use two solutions for post-receive hook:
DEPLOY SOLUTION 1
DEPLOY SOLUTION 2
Both solutions are based on earlier solutions available in this thread.
Note, the BRANCH_REGEX='^${GIT_BRANCH1}.$' filters for the branch names matching "master" or "dev*" string, and deploys the work tree, if the pushed branch matches. This makes possible to deploy a dev version and master version to different places.
DEPLOY SOLUTION 1 removes only files, which are part of the repo, and was removed by a commit. It is faster than Deployment Solution 2.
DEPLOY SOLUTION 2 has the advantage, that it will remove any new files from the production directory, which was added on server side, no matter if it was added to the repo or not. It will be always clean dupe of the repo. It is slower than Deployment Solution 1.