How to force the checkout of the latest revision from a remote server?
git
Solution
JB's right, but I'm going to expand a bit on his answer.
Instead of having the server automatically run `git pull`, you should have it run `git fetch origin; git checkout origin/master`. Of course, this assumes that you've got the "origin" remote set up to refer to your local computer's repo.
If you ever need to modify the server sources directly (for a quick fix, or whatever) and want to commit those changes, you can `git branch -f master origin/master` before you do the commit to get the server's master branch set to the same commit as the local computer's branch.
Problem
I have repository on GitHub to which I commit regularly from my local computer. On the other side I have server pulling from the repository. The web server just executes a `git pull` in order to get the latest changes from the GitHub repository. This is completely automated and should stay that way (solutions like the Ruby Tool Capistrano are out). A simple `git pull` usually works just fine. However, sometimes I change the last commit (`git commit --amend`) and `git push` the changes twice to GitHub. If the server auto-updated it's code between the two pushes to GitHub, the next server side `git pull` fails because there is merge conflict. To solve this problem I need the following behavior: The server should continue to `git pull` (or something equivalent) the GitHub repository but in case of a merge conflict, the GitHub repository should just take precedence over the local repository on the server. So, I want a git command that behaves like `git clone`, but doesn't copy the whole repository every single time.