Here is the scenario:
-
I clone the staging branch of my codebase:
git clone -b staging git@my.giturl.com:/my-repository.git . -
I make a change elsewhere and push it to the origin
-
I attempt to pull my changes to my checkout:
git pull origin
The previous statement fails giving me this:
Updating 7bb2dae..f711fb0
error: Your local changes to the following files would be overwritten by merge:
sites/all/modules/broker_auth/broker_auth.module
Please, commit your changes or stash them before you can merge.
Aborting
broker_auth.module is the file I changed elsewhere, but locally nothing has been touched. Why does it say it has changed? The only way I can fix is to do the following (which takes a while, perceivably because it’s redownloading the entire repository)
git reset --hard
git pull origin
Is it really required that I do a reset in this situation? I feel like I’m managing my branches incorrectly but I’m having trouble figuring out what is happening.
I found the cause of my issue. It ended up being my server was changing the permissions of my files so all the files were being marked as modified. I ran the following command
git config core.filemode false, which essentially ignores filemode changes, and now my fetches work first time everytime. Hope this helps someone having similar issues.