Saturday, April 18, 2015

Removing git Untracked files

You can mess up git working directory by merges, mistakes etc. and ends up with lots of unwanted untracked files,


You can use .gitignore to discard those files from the working directory, but that is not the only available option. .gitignore is perfect option to discard .project, target, .swp files permanently from the working directory. But what if we want to discard few files just once.

git clean is the solution, you can decorate this command by providing various parameters. Here in this post I'm focusing only -d, -n and -f  options.

-d, will do a dry run on the working directory, so you can find out what are the files/directories going to be removed.




If you provide the -f option and remove -n based on the permission, this will actually perform the task of removing those listed files.


Make sure to double check while performing this trick.

No comments:

Post a Comment