For my continuous integration builds, I want to make sure no stray files have been deposited in my git sandbox, and none of the files have been inadvertently changed.
I know about git reset --hard HEAD
, and this solves part of the problem. But I guess what I want to do is delete all the untracked and ignored files. I could do it the brute force way and just do:
rm -rf *
git checkout -f
But there must be a more efficient way to do it. Any ideas?
(Expanded for posterity)
Your problem can be split in two: Returning modified files to their state in the last commit and removing any extra files that don't belong in the repository:
git reset --hard HEAD
will take your files back to the state they have in HEAD, removing any modifications (even if they were stage to be commited)
git clean -f -d -x
will remove any untracked files or directories, including ignored files (Thanks to @Jefromi)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With