Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitBucket: error: Your local changes to the following files would be overwritten by merge

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.

like image 408
Simon Davies Avatar asked Aug 12 '13 09:08

Simon Davies


People also ask

How do you fix error your local changes to the following files would be overwritten by checkout?

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?

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.

How do you stash them before you can merge?

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.


1 Answers

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
like image 161
Simon Davies Avatar answered Nov 07 '22 10:11

Simon Davies