Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

  1. Make a change on a file at Github repo
  2. Run a bash script (as apache) via web from live server that attempts a git push / pull. Get these problems:

    ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to ''
    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.
    branch            master     -> FETCH_HEAD
    error: unable to unlink old 'includes/' (Permission denied)
    Updating 8f6d922..d1eba9d
    Updating 8f6d922..d1eba9d
  3. SSH in as root, attempt a push / pull and it works fine.

Ideas on why would this method does not work from apache?

share|improve this question

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’ve pushed and pulled as root.

chown -R is your friend.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.