Paul Draper
Paul Draper

Reputation: 83393

Ignore text=auto in .gitattributes file

I checked out a branch foo, and now I want to switch to branch bar.

error: Your local changes to the following files would be overwritten by checkout:
<300 files follow>

Someone has a .gitattributes file on foo that includes

text=auto

All of the "changes" are newline changes.

I could remove the file, switch branches, and then add it back.

rm .gitattributes
git checkout bar
git checkout .gitattributes

Is this the best (fastest/least typing) way?

EDIT: To be clear, I just want to switch branches. I'm only reading the repo. I don't want to change anything other than the working tree. But I can't.

Upvotes: 4

Views: 700

Answers (1)

VonC
VonC

Reputation: 1329082

I just want to switch branches. I'm only reading the repo.

Then removing the .gitattributes is indeed one possible solution, provided you don't try to checkout again foo once on bar (or that .gitattributes would appear again)

Another option would be to simply clone the repo directly at the bar branch, creating a separate working tree.

Upvotes: 1

Related Questions