A teammate has created a rather sticky problem by way of the .gitattributes file, specifying some line ending magic (aka rewriting) to occur.
The result is that whenever his branch is checked out, git thinks changes were made to various files, even with a fresh checkout. Thus normal attempts to blow away local changes fail, because like I say, the files are "changed" from the start.
The most annoying part is that once this branch gets checked out, it is very hard to ever "leave" this branch, because any attempt to checkout another branch is met with
error: Your local changes to the following files would be overwritten by checkout
My question: how can I force git to checkout another branch and discard my local "changes" when the changes were made by git itself? Here are some attempts that did not work:
git checkout .
(it still says local changes were made)git clean -f
Here's what does work:
rm .gitattributes; rm -rf *; git checkout someotherbranch
Is there any less drastic approach to escape this .gitattribute problem?
Well turns out the answer is so stunningly simple I almost don't trust it, but it seems to work. Add -f to force the checkout:
git checkout -f someotherbranch