Reputation: 22217
Is it possible (without doing a git clone again) to bring by repo to a "clean" state, in that also files, which are manually created, are removed?
I have a directory which is gitignored:
# .gitignore
mydir/
The directory mydir has been manually created and contains files. When I do a
git clean -X -f .
in the base directory of my repo, mydir is not removed. This seems to be in concordance with the documentation, as we can see here.
My question is now: What would be the best way of cleaning my repo? I could rm -rf
my repo and then run git clone
, but maybe there is a "better" way to do it?
Upvotes: 2
Views: 57
Reputation: 43314
You are looking for the -d
flag
-d
Remove untracked directories in addition to untracked files. If an untracked directory is managed by a different Git repository, it is not removed by default. Use -f option twice if you really want to remove such a directory.
and the -x
flag
-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.
When you do a $ git clean -xdf
using -x
and -d
together it will also remove untracked/ignored directories
Also see http://git-scm.com/docs/git-clean
Upvotes: 5