I have a web interface for deploying scripts from our repo at Github to our live server. The web interface just triggers a bash script with some git commands. If I make changes locally, push to repo, then run the bash script to pull from repo to live it works fine. However, if I make changes directly in the repo (via Github's web interface), I'm running into fast-forward / lock issues.
These are the steps I'm taking:
- Make a change on a file at Github repo
Run a bash script (as apache) via web from live server that attempts a git push / pull. Get these problems:
PUSH To [email protected]:name/name.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[email protected]:name/name.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. PULL From github.com:name/name branch master -> FETCH_HEAD error: unable to unlink old 'includes/footer.inc' (Permission denied) Updating 8f6d922..d1eba9d Updating 8f6d922..d1eba9d
SSH in as root, attempt a push / pull and it works fine.
Ideas on why would this method does not work from apache?
Because the files in your local copy of the repository aren’t owned by the web server user. At least some of them are probably owned by
root
, given that you’vepush
ed andpull
ed asroot
.chown -R
is your friend.The push is failing because you've got diverging history. You need to merge the changes in your local repository into the current remote branch, and then push that result to Github. See ProGit for the gory details of that operation.
The pull is failing because, as Mo said, you've got permissions problems.