git pull on staging server failing because of local changes

On my staging server I have a cron job that does a git pull every two minutes, most of the times everything works fine, but sometimes I notice that the changes that I pushed to the repo are not pulled, when I inspect the issue and run git pull manually I get an error:

error: Your local changes to the following files would be overwritten by merge:
{the file(s) that I had pushed to the repo}
Please, commit your changes or stash them before you can merge.

I don’t understand how these changes are being considered “local changes”. any help?

  • Versioning multiple projects with versioneer within a single git repository
  • What is a recommended way to manage git patch queues in unrelated repositories
  • Why does re-merging result in a repeated merge conflict in git?
  • Are there any accepted “best” or canonical books on SCM for developers?
  • Git in PHPstorm: Unstage files from Git
  • GIT Dev/Testing/Production Enviroment Best Practices
  • How to make a new branch on pull conflict?
  • Why do merge conflicts happen?
  • One Solution collect form web for “git pull on staging server failing because of local changes”

    I mentioned before (“Cannot pull with rebase”) that git rebase learned the --autostash option (git 1.8.5+).

    You could combine that with a reset –hard in order to make sure the end result of your scheduled git upll is always a clean state:

    git config rebase.autostash true
    git pull -rebase
    git reset --hard
    

    That assumes you have no local commit or work in progress on the repo updated by your git pull (or it would be erased by the reset --hard)

    The autostash option ensure that the untracked state of the working tree (for whatever reason) is not blocking the git pull.
    And the reset --hard should make sure the working tree is clean.

    Git Baby is a git and github fan, let's start git clone.