Ian Jay
Ian Jay

Reputation: 92

Git no changes to commit but can't switch branch

I am working on windows. Using Git I am trying to switch to another local branch but it won't let me due to this error:

Your local changes to the following files would be overwritten by 
checkout:
codelibrary/inc/variables.php 

But when I do git status on my current branch, I get:

nothing to commit, working tree clean

I've seen 2 questions that are the same as mine in these links:

  1. git status shows modifications, git checkout -- <file> doesn't remove them
  2. can't checkout a git branch - need to commit changes, but no changes are present

But none of the answers seem to solve my problem.

I suspect I had the file ignored in my current branch but not in the branch I want to switch to.

I'm new to git so I would like to ask the git pros to please help me with this.

Upvotes: 1

Views: 911

Answers (1)

padawin
padawin

Reputation: 4476

This happens when you have an untracked file in your path which is tracked in the branch you try to checkout. Git will not know what to do with this file (which one to use between the tracked and the untracked one, so it refuses to checkout the branch.

Upvotes: 4

Related Questions