Reputation: 3686
I have searched everywhere and tried various solutions but am still getting the error: Your local changes to the following files would be overwritten by merge
i have nothing to commit as status tells me the following:
# On branch develop
# Your branch is behind 'origin/develop' by 1 commit, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
nothing to commit, working directory clean
So then I do a git pull, then get the following:
Updating 67020e6..6dd23de
error: Your local changes to the following files would be overwritten by merge:
app/filename.php
Please, commit your changes or stash them before you can merge.
Aborting
But as I have nothing to commit and if I do a git stash I get No local changes to save
So how can I fix the problem and download and update my local machine with my remote amends.
Bit of history incase: I have to local machines one at home and work I have done the amends at home and pushed them and I am now trying to update my local work machine with these updates.
EDIT UPDATE As I cannot answer my own question for a while I found what for me solved this answer:
on the branch I wrote:
git reset --hard
Then the pull worked.
Upvotes: 8
Views: 10203
Reputation: 3686
While looking around i tried the following that seemed to fix my issue at the time.
While on the branch i wrote.
git reset --hard
Upvotes: 7
Reputation: 1338
Faced exactly the same problem. I was used to CVS before I started exploring git. I think running git pull --rebase origin master
is the way to go for the kind of workflow that you and I use.
Refer to https://www.atlassian.com/git/workflows#!workflow-centralized for a more detailed explanation. I definitely know the answer is somewhere in that article, but I didn't understand the article completely.
Upvotes: 0
Reputation: 37827
Had you ever previously done git update-index --assume-unchanged <file>
? That could be a potential reason for your situation.
To fix, you do git update-index --no-assume-unchanged <file>
. Then you should be able to stash your changes and continue with the merge.
Upvotes: 2