开发者

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

开发者 https://www.devze.com 2023-03-11 12:53 出处:网络
I\'m working with TFS 2010 and I need to edit a file lo开发者_StackOverflow社区caly without checking it out.I want to be able to edit the file in VS2010, is this possible? The defective \"Save as\" di

I'm working with TFS 2010 and I need to edit a file lo开发者_StackOverflow社区caly without checking it out. I want to be able to edit the file in VS2010, is this possible?


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.


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.


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".

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


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.


I believe you are looking for this:

  1. Edit your VS options like this:

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

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

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

  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.


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.


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


'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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号