简体   繁体   中英

Git not pushing new files to remote repository

I am using a push-to-deploy method to put out changes to a project. How I've done this is as follows:

  1. Setup a local git repository for current project and commit files
  2. Copy full project directory to remote location (eg /var/www/myproject) including myproject/.git directory
  3. 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.
  4. Setup a post-update hook on the remote server mainly to git reset HEAD and git checkout . This will overwrite the previous version on remote directory with the newly pushed version.
  5. Add the new remote git directory to local.
  6. 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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM