I am using a push-to-deploy method to put out changes to a project. How I've done this is as follows:
git config receive.denyCurrentBranch false
for this project on the remote server (if I set this to true I get errorrs) to allow me to push from dev. Otherwise I get an error telling me to do so. git reset HEAD
and git checkout
. This will overwrite the previous version on remote directory with the newly pushed version. This works fine and my changes to files appear in the checked out branch on the remote server. I only have one remote repository too this way. Previously I had a bare repository and used a post-update hook there to pull the project to the live directory (resulting in two repos on remote - bare and pulled repo)
Anyway, where this isn't working is when I create a NEW file on my local development environment and add, commit and push the changes. I don't get any errors. Also, if I try to push again it tells me that everything is up to date. But, the new file is not on the remote server. Why?
I'm not sure if the new files aren't being commited to local git, pushed to remote or not checking out. Is there any reason for this? Do I need to specify some option somewhere?
UPDATE
If I try to checkout the file in development on my local repo it's fine. So it seems the file has been commited to there. So at some point between pushing to remote, and then reset/checkout there I've not set things up correctly.
My advice is to use only one bare
repo on the remote server with combination of post-receive
hook.
The hook should look like:
git --work-tree=/path/to/the/live/site checkout -f master
For the missing file I guess the issue is that you are commiting the file in different branch, say dev
and on the live server you are checking out the branch master
where this file do not exists.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.