Issues with git branch checkout due to untracked working tree files

I thought I put the days of Xcode + git issues behind me. Guess not. I am getting this git error when trying to checkout another branch.

error: The following untracked working tree files would be overwritten by checkout:
Please move or remove them before you can switch branches.

Very well I say, let me remove these files:

  • Git : How to reset the history of all the repositories associated with a project?
  • Edit last pushed commit's message
  • Git - Where do files go when you change branches?
  • How to resolve Deleted merge conflict in TortoiseGit?
  • Composer - No Matching Package Found
  • Git: How do I merge complex branches that have widely diverged with some missing history?
  • andrewjl$ git rm --cached RCAlpha.xcodeproj/project.xcworkspace/xcuserdata/andrewjl.xcuserdatad/UserInterfaceState.xcuserstate
    fatal: pathspec 'RCAlpha.xcodeproj/project.xcworkspace/xcuserdata/andrewjl.xcuserdatad/UserInterfaceState.xcuserstate' did not match any files

    At this point I’m not sure what to do. These files are all listed in my .gitignore and I also gave git clean -f -d a try as well. No dice. Anyone know what’s going on here?

  • Squash git commits that are ancestors of multiple branches
  • 'git' cannot be made visible because all of its children are in unavailable action sets
  • Can not access via ssh and view layout without css
  • How to split last commit into two in Git
  • git error unpack failed missing blob on git review to gerrit
  • View git changes/diffs of local commits not pushed to remote
  • 2 Solutions collect form web for “Issues with git branch checkout due to untracked working tree files”

    The files are untracked: git rm --cached cannot find them because there are not in the index. Just delete them, using your file manager or rm. Then checkout should work as expected. Note that git status will show you what git sees the files as (tracked, changed, untracked; with an additional option it will also display ignored files).

    they arent in git but there locally .. that means when you switch those would be lost and git doesnt allow that

    remove them locally:

    rm RCAlpha.xcodeproj/project.xcworkspace/xcuserdata/andrewjl.xcuserdatad/UserInterfaceState.xcuserstate RCAlpha.xcodeproj/xcuserdata/andrewjl.xcuserdatad/xcschemes/RCAlpha.xcscheme RCAlpha.xcodeproj/xcuserdata/andrewjl.xcuserdatad/xcschemes/xcschememanagement.plist

    they are recreated by xcode anyway. nothing important in there!

    Git Baby is a git and github fan, let's start git clone.