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.
The Git “Your local changes to the following files would be overwritten by checkout” error occurs when you make changes on two branches without committing or stashing those changes and try to navigate between the branches. You can fix this issue by either stashing your changes for later or adding them to a commit.
Will git merge overwrite my changes? With default strategy and default text merge driver, if there is no conflict, git never overwrites anything at merge. If there is a conflict then what "git does" fully depends on how person performing merge resolves the conflicts.
The “commit your changes or stash them before you can merge” error is raised when you try to pull code from a remote repository that conflicts with a local change you have made to a repository. To solve this error, either commit your change to the repository, discard your change, or stash your change for later.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With