Rossini
Rossini

Reputation: 6048

How to Edit a File in VS2010 & TFS w/o checking the file out

I'm working with TFS 2010 and I need to edit a file localy without checking it out. I want to be able to edit the file in VS2010, is this possible?

Upvotes: 8

Views: 12178

Answers (8)

Liu Kang
Liu Kang

Reputation: 46

The defective "Save as" dialog Rossini refers to above is a known bug in VS 2010, with the official response being "Won't fix"

https://connect.microsoft.com/VisualStudio/feedback/details/765219/tfs2010-save-as-dialogue-does-not-overwrite-an-un-checked-out-file-when-solution-is-open#

This effectively makes it so you cannot use "Edit: Do Nothing" and removing the read-only attribute as a way to work with single files offline without a check-out. So from all the work I have done the answer to this question is "you cannot", at least not in any effective way.

The alternatives (none of which are reasonable, usable, or accomplish what you want in scratchpad file editing) are to take your whole solution offline or only load the file directly in a separate instance of Visual Studio (that is, outside of the Solution), at which point you lose a bunch of references and Intellisense and might as well use Notepad++.

I just wanted to get this final information out for those (like me) who have searched for a way to do this. The last time I checked this was still broken in VS 2012 as well.

[Edit] I have not looked at any of the plugins or addons mentioned, only off-the-shelf Visual Studio.

Upvotes: 3

Mrchief
Mrchief

Reputation: 76258

I believe you are looking for this:

  1. Edit your VS options like this: enter image description here

  2. Edit your file and click Save. At this point, you'll get a warning dialog like this: enter image description here

  3. Hit Ok and then modify the file's read-only attribute and then save again. This will allow you to save your edits without checking out.

Upvotes: 1

Garf
Garf

Reputation: 25

'I want to recompile my project with my local changes'. You should be working WITH your source control, not against it.

Make a version of your code with your local changes. Check that in. Now label it. Go back and get a version of your code prior to your revision for local changes, edit the file pasting in that content, and check that in. Now when you compile local, get the labeled version of your code, and recompile. Yes, you will have the changes checked in, but the latest version of the code will not have the version with your local changes. Be creative with your label, and put a descriptive label on it so other developers will understand what it is for.

This is assuming it is a single file. In VSS, you could do something similar with 'pinning' the code. Regardless of the number of check ins after the pin, other users would only get the pinned version. In TFS, there is no equivalent to pinning (thank the gods). You could do something similar with branching, but you certainly wouldn't want to do that for a single, throw away piece of code for experimental local use.

Upvotes: -3

Mike Veigel
Mike Veigel

Reputation: 3815

To directly answer the question "is this possible" the answer is yes depending on what you want to do.

You can edit the files and do whatever you want to do locally without a risk of checking the file. Make sure your solution is closed before you run the TFPT tweakui command then open it back up inside Team Explorer. Make sure you are in the correct folder when running the command. Use TFS 2008 Powertools to do this.

However...

When you sync back up, it will check the files out automatically that have the read-only flag removed. So what you would need to do is add the flag back and rollback your changes after you were done with your local testing.

Maybe you can describe why it is important that the file not be checked out in the first place and the community can help you work around that issue? For everyday development, this workflow is somewhat error-prone and requiring the use of TFS Powertools is pretty heavy-handed in my opinion.

At any rate, I hope that gets you headed in the right direction there are plenty of other comments here that are helpful as well

Upvotes: 0

James Reed
James Reed

Reputation: 14052

You can tell VS / TFS not to check out on edit, Tools / Options / Source Control / Environment

Change Saving to "Prompt for checkout" and Editing to "Do nothing".

TFS Checkout Options

Upvotes: 2

Scott Bruns
Scott Bruns

Reputation: 1981

In VS2008 from the menu choose Tools|Options|Source Control|Environment.

Check Allow checked-in items to be edited.

I'm guessing this will also work in VS2010.

Upvotes: 0

Duat Le
Duat Le

Reputation: 3596

You can edit a local file in Visual Studio without checking it out by remove the read-only attribute on the file (DOS command: attrib -r). The editable file will not show up in your workspace's pending changes.

Leaving a lot of editable (writable in TFS-term) files in your local workspace will increase the number of merge conflicts when you do a get latest, and someone else has changed these files. You can search for these editable but not checked out files in your local workspace using the TFS command line power tool: "tfpt.exe online".

More information on the tfpt commands can be found here.

Upvotes: 2

Scott Bruns
Scott Bruns

Reputation: 1981

Yes. Get the file and then disconnect from TFS (Work Offline). You will not check out the file.

Or just edit the file and do not check it in. Undo the changes and the file will never be checked-in.

Upvotes: 1

Related Questions