Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug git error: "Your local changes to the following files would be overwritten by checkout" when there's nothing to stash?

Tags:

git

git-svn

I'm using git-svn, and I'm trying to run git svn rebase.

I get the error:

Your local changes to the following files would be overwritten by checkout:
<filename>
Please, commit your changes or stash them before you can switch branches.

I have previously run git update-index --assume-unchanged <filename>, and made changes to the file, but I've now run git update-index --no-assume-unchanged <filename> to get rid of that.

git status doesn't report any changes and git stash says there's nothing to stash.

I have checked that the file is not in .gitignore or .git/info/exclude

How can I debug this problem further?

like image 477
Tim Bellis Avatar asked Dec 20 '12 17:12

Tim Bellis


1 Answers

I was having this problem and Tim's answer helped me figure out the solution.

In the past I had run:

git update-index --assume-unchanged index.php

The Problem

After making a bunch of changes to another branch remotely, I was getting the overwrite warning while trying to switch over locally.

git checkout other-branch

error: Your local changes to the following files would be overwritten by checkout:
index.php
Please, commit your changes or stash them before you can switch branches.
Aborting

Stashing wasn't working.

git stash save --keep-index
No local changes to save

The Solution

git update-index --no-assume-unchanged index.php
git add index.php
git commit

After that.

git checkout other-branch

Success!

like image 153
DoerCreator Avatar answered Sep 27 '22 20:09

DoerCreator