I am using a push-to-deploy method to put out changes to a project. How I've done this is as follows:
- Setup a local git repository for current project and commit files
- Copy full project directory to remote location (e.g. /var/www/myproject) including myproject/.git directory
- Set
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. - Setup a post-update hook on the remote server mainly to
git reset HEAD
andgit checkout
. This will overwrite the previous version on remote directory with the newly pushed version. - Add the new remote git directory to local.
- Add, commit and push changes to remote repo. Remote project files should be the current 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.