Remove untracked files from a local directory
Scenario: Someone made some awesome changes to your repo and you want to check them out.
So you do the following
git checkout -b my-killer-changes origin/my-killer-changes
and just before you can really dive into it, the biz dev ppl walk in with a major PRIORITY that can't wait till the next iteration. Literally EVERY SALES OPPORTUNITY rests on you implementing this feature.
So you checkout master, cut a branch, make your changes, and go to commit..
git checkout master
git checkout -b biz-dev-fix
coding.....
git status
OH, snap. All those files from my-killer-changes
are showing up in your untracked files.. Not a big deal really, but it's highly annoying if your trying to make sure you get all the files you had to create bundled in the same commit..
SO- add this tiny git command to your workflow to resolve this problem
git checkout master
git clean -f
git checkout -b biz-dev-fix
coding...
git status
Now you have a nice clean working directory for when you create that new branch.. Oh and if your not sure what all clean will delete, run git clean --dry-run
to see what "would" happen.
https://www.kernel.org/pub/software/scm/git/docs/git-clean.html