0

I have a problem when I try to checkout to a branch. Im getting the error:

Please, commit your changes or stash them before you can switch branches.
error: The following untracked working tree files would be overwritten by checkout:
        build/classes/bp/conf/db/user.sql
        build/classes/bp/conf/db/user_group.sql
        build/classes/bp/conf/db/user_info.sql
        build/classes/views.properties

I cannot stash or commit them because those files are included in the .gitignore.

Please help.

Zoe
  • 27,060
  • 21
  • 118
  • 148
kwan_ah
  • 1,061
  • 1
  • 12
  • 18
  • sounds like they are in your gitignore, but actually in the branch you are switching to. – Paul Dixon Jun 11 '13 at 07:47
  • `git stash -u` for untracked files? Apparently you're going from a place where they are not ignored to where they are checked in, so checking them out would overwrite those in your work directory, even though they are now ignored. – steabert Jun 11 '13 at 07:55

2 Answers2

2

The branch you are switching to has these ignored files checked in, so you need to do something with them.

Either delete them, move them out of the way, git stash them, or commit them.

If you want to commit them, use git add -f to force them to be added.

Paul Dixon
  • 295,876
  • 54
  • 310
  • 348
0

I just solved it with rm -r build/ to remove untracked files and continue checkout to a branch. :)

kwan_ah
  • 1,061
  • 1
  • 12
  • 18