标签云

微信群

扫码加入我们

WeChat QR Code

Possible Duplicate:
How do you remove untracked files from your git working copy?

Is it possible to tell git to remove untrack files? Mainly something that is similar to a reset?

example:

git checkout -- index.php <-- revert my file
git checkout -- master <-- this would revert the entire repo back to the last commit on master, removing (deleting) any and all untracked files as well as reverting committed ones.

I know this is trivial todo on the shell, but I'd like to know if this can be done in Git?


git checkout -- master will not check out branch master, but will check out the file called master at the current commit (HEAD)

2018年08月15日26分12秒

Sorry this is a duplicate.

2018年08月16日26分12秒

I have to use -f instead. -x seems to not work for me, got this error: fatal: clean.requireForce defaults to true and neither -i, -n nor -f given; refusing to clean

2018年08月16日26分12秒

Hlung: It looks like the default for your Git installation is to require -f. So you would use git clean -f -x.

2018年08月16日26分12秒

upvote indeed. git-scm.com/docs/git-clean

2018年08月16日26分12秒

This is the ultimate answer to the question. Accepted answer clears the inside of an untracked directory but leaves the directory's itself.

2018年08月16日26分12秒