I'm looking for a way to keep several client boxes in synch with a remote git repo. Forcing updates from the remote repo and abandoning anything that may have changed on the client boxes.
The problem I'm running into is that the client boxes will modify some of the files (installation logs etc.) and gives me a merge nightmare when I need to update them from the remote repo. I've tried several commands to try and reset their local changes (the local changes should just be abandoned), but none seem to be working as advertised (git reset --hard).
I don't want to do a clone and then delete the .git dir on these boxes as I'd prefer them to only update with changes rather than pulling down the entire repo every time.
Any ideas?
解决方案
I'm assuming you have a good reason for using Git for this, rather than rsync.
This is how I'd do it (on the Clients):
git fetch origin
git reset --hard origin/master
git clean -dfx
Note that you need to reset to origin/master rather than HEAD because the local HEAD doesn't include the origin's newest commits (yet).