From: lamikr Date: Mon, 09 Jan 2006 22:36:22 GMT Subject: Re: undoing changes with git-checkout -f Message-ID: <43C2E566.2060006@cc.jyu.fi> In-Reply-To: Linus Torvalds wrote: >You should realize that git _does_not_know_ about your file. You never >even told git about it. So git won't ever evenlook at it, much less delete >it. > >So when you do a "git checkout -f", what that does is to rewrite all the >files that git KNOWS about. Any files git doesn't know about will not ever >be touched. Your "1.txt" file might as well be an object file, for all git >knows. And git won't remove your object files or any other files that it >doesn't know. > >(Now, in all fairness, even if you had done "git add", I don't think git >will remove the file. If you committed the file and then checked out the >previous version, _then_ it would remove the committed file). > > Now that you say it, I got it, thanks. I expected earlier that git would perform also the remove of non-added files as other commands like "git-commit" are anyway aware if you have files in your working dir that have not yet added. >If what you want to do is to clean the git directory of all files that git >doesn't know about, you can do that with > > git-ls-files -z --others | xargs -0 rm -- > > Thanks for the tip. I have now added alias git-reset-ff='git-ls-files -z --others | xargs -0 rm --' And git-reset-fff (forte fortissimo) would probably blow the whole hd away :-) Mika