Gergely Polonkai <> writes:

> Hello,
> TL;DR: no, your branch is not polluted, your working directory is in a
> dirty state.
> A branch is just a pointer to a commit, so if it gets “polluted”, that
> would mean your last commit has changed.
> What happened is that your changes in the working directory (which, before
> you modified your file, is the representation of your last commit) has been
> left intact. This is Git's way to protect your work; if, for any reason,
> the modified file has been changed on your master branch (like by a
> commit+push from a fellow developer), Git would refuse the checkout
> altogether for the very same reason: the checkout would overwrite your
> uncommitted changes.
> Now if you really want to abandon that change, you should reset that file
> to the same state as it was in the last commit. Surprisingly (well,
> somewhat), this is done by git checkout HEAD:your/modified-file.txt, not by
> git reset (as I expected a few years ago). This checkout command will drop
> your changes to that file, so when you checkout your master branch, it
> won't “pollute” it.

Of course `git reset` *can* be used to do it, you just have to tell it
to be hard :)

   git reset --hard HEAD


Magnus Therning              OpenPGP: 0x927912051716CE39
email:   jabber:
twitter: magthe     

If our ideas of intellectual property are wrong, we must change them,
improve them and return them to their original purpose. When
intellectual property rules diminish the supply of new ideas, they
steal from all of us.
     — Andrew Brown, November 19, 2005, The Guardian

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Attachment: signature.asc
Description: PGP signature

Reply via email to