Often, I execute git reset --hard along with git clean -f
in order to clean-up my branch from modifications and build files.
This command, deletes all the untracked files, which is OK for me, but there are few files I want to stay, such as .project or .settings (for eclipse)
These file are not part of the repository, and declared in the .gitignore file.
is there a way to keep these files when issuing the above commands, or maybe I should you different commands for that ?
Note that
git clean-fshould only removed files unknown to git, not ignored files.Only
git clean -f -xwould removed ignored files.(in all cases, a
git clean -n -...is better, to have a preview of what would be removed)The advantage of
git resetovergit cleanis mainly about moving HEAD and resetting the index as well as the working tree.git cleanis only about the working tree.