Jackson Pope
Jackson Pope

Reputation: 14640

TFS can't check in changes after replacing file

I'm re-writing an Asp.Net project that a colleague had done a prototype version of. I deleted the Default.aspx and created and new one and now I'm trying to check that new version in.

When I try to check in pending changes I get the standard:

Check In, No files checked in due to conflicting changes. Please use Conflicts Channel to resolve conflicts and try again.

I'm re-directed to the Pending Changes - Conflicts tab, where I'm presented with the options: 'Take Server Version' or 'Keep Local Version'.

If I click 'Keep Local Version', I get the following error:

Error, The following exception was encountered. The item $/ProjectName/Default.aspx already has pending changes.

How can I get it to accept my new version of the file?

Upvotes: 4

Views: 16725

Answers (3)

Mr. Squirrel.Downy
Mr. Squirrel.Downy

Reputation: 1177

The edited files are no longer with read-only status.
So this is the solution:

  1. Close the project. (Or use TfsGoOffline, I love this, you can skip 2, 3, 4)
  2. Disconnect internet.
  3. Open the project and it will now in offline mode.
  4. Reconnect to the Internet.
  5. Right-click the solution and select "Online".
  6. VS will checks all files that are not "read-only" and treats them as "changed" and mark as check out.
  7. Now all files that have been replaced are successfully checked out.

Upvotes: 0

Mike Gledhill
Mike Gledhill

Reputation: 29201

We've just spent 30 minutes fighting with TFS due to this problem.

A colleague had checked in a file, and we wanted to rollback to a previous version. TFS would let us check-out that file, use History, and get the older version, but as soon as we hit Save, VS2015 would immediately "un-check-out" the file, revert back to the latest version of the file in TFS and we lost our changes. No warnings, no possibilities to prevent it.

Other times, we'd do a Check-in, but TFS would complain "No files checked in due to conflicting changes", and, again, revert us back to the latest version from TFS, with no options to prevent this.

What finally worked for us was to

  • check out the file
  • set it's contents to the older version (which is what we wanted)
  • open the folder where it was stored and set the file to Read-Only
  • check in the file

By doing this, TFS didn't automatically overwrite our file with the latest code from TFS, and we were able to check in the version we wanted to.

I need a beer...

Upvotes: 2

Sounds like there's a newer version of that file on the server side. Copy your local file somewhere, then discard your changes and get latest. Then check out and overwrite the checked-out version with your local file. Perhaps there's a more elegant way to do it, but it should work - and of course it will also overwrite any changes made to the server-side version.

Upvotes: 21

Related Questions