Yoeri
Yoeri

Reputation: 1906

How can I avoid an encoding conflict when merging files in TFS?

We are working on a large codebase in Visual Studio 2010 using TFS as version control system.

When performing merges we recently get a lot of encoding issues. For the most of them we get an option "Choose encoding and merge" for other files we get:

"The encodings for the files being merged must match or an encoding conversion must be specified."

We normally put every file in UTF-8, although we get conflicts when merging between codepage 1252 and utf-8.

To solve these issues we always perform a manual merge which can be quite cumbersome. How can we avoid these errors? What is the recommended encoding for source-code files in TFS? How can we recursively set the encoding to avoid errors like these in the future?

Upvotes: 4

Views: 5024

Answers (1)

Holistic Developer
Holistic Developer

Reputation: 2526

You are getting the message because TFS thinks (correctly or incorrectly) that a file has different encodings in different branches. To double-check the encoding, go to the properties window of any source-controlled file.

Although TFS detects the encoding when a file is added to source control, if the encoding is later changed TFS will not always pick it up. Click the Set Encoding button and then click Detect to see what the actual encoding is. If it isn't what you expect, then check out the file, modify the encoding in a text editor, and then have TFS re-detect the encoding.

Once the encoding is the same in both branches you shouldn't get this error any longer.

Upvotes: 4

Related Questions