I am no my local my-feature
branch
git status
reports nothing to commit, working tree clean
I want to switch to develop branch and do git fetch
and git merge
there (I prefer it over git pull
)
However, doing so produces error below
Here I first check status and it shows that all is clean
mymbp:MyProj username$ git status
On branch my-feature
nothing to commit, working tree clean
Next I try to checkout my develop branch which is an existing local branch
On branch my-feature
nothing to commit, working tree clean
mymbp:MyProj username$ git checkout develop
error: Your local changes to the following files would be overwritten by checkout:
MyProj.sln
Please commit your changes or stash them before you switch branches.
Aborting
It complains that myProj.sln
has been changed even though git status
says nothing has changed.
Issuing git status
again, confirms that nothing has changed
mymbp:MyProj username$ git status
On branch my-feature
nothing to commit, working tree clean
Hi @dbnex
If you change your file in your editor and save it, it will be recognized as a change. It isn't until the file is committed will git allow you to move on to a different branch.
Option 1
Discard any changes in current branch. Via the command below.
git checkout -- .
Next, switch to new branch and continue working
git checkout -b new-branch
Option 2
https://git-scm.com/docs/git-stash
I prefer Option 1 as then I don't have a loose thing to come back and deal with later. Extreme Coding principles being what they are :)
Hope this helps!
@BillyP Thanks Billy but I am not sure you understand my question.
Option 2 makes no sense since git status, git diff, stash show that there is nothing changed, working tree is clean. But git checkout sees this one file as changed, this is all in question above.
Option 1 makes no sense to me since all I can find about git checkout -- seem to be related to file and directory named same way, I dont have that in my case.
I posted this question and added some more updates here to clarify https://stackoverflow.com/questions/53214095/git-checkout-errors-even-though-git-status-reports-that-working-tree-is-clean
Thanks for your suggestions,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.