Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

    PUSH
    To git@github.com:name/name.git
    ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com: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
    
  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

2 Answers 2

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

 
discard

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.