mnosefish
mnosefish

Reputation: 379

git untracked file error on branch change

I'm trying to switch branches on a newly-cloned repo on my Windows machine:

$ git checkout hybridClass
error: Updating the following directories would lose untracked files in it:
    Scripts\/

Aborting

my commits are current:

git commit -m "message"
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

I can't seem to find these untracked files:

git clean -d -n

(no output)

I have successfully checked out this branch before (on another machine), so I'm not sure what's going on here. My apologies if this is a duplicate; none of the similar posts seemed to be quite appropriate.

Edit: added git status output

git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

Upvotes: 0

Views: 1312

Answers (1)

CodeWizard
CodeWizard

Reputation: 142164

git clean -d -n

Add the -x flag to your clean to remove the untracked files as well

-x

Don’t use the standard ignore rules read from .gitignore (per directory) and $GIT_DIR/info/exclude, but do still use the ignore rules given with -e options. This allows removing all untracked files, including build products.

This can be used (possibly in conjunction with git reset) to create a pristine working directory to test a clean build.

Upvotes: 1

Related Questions