How to have TFS 2010 detect changes done to files outside of Visual Studio?
Asked Answered
R

11

122

I'm using Team Foundation Server 2010 with Visual Studio 2010.

Whenever I modify a file outside of Visual Studio, TFS doesn't seem to detect the change done to the file, and thus doesn't offer me the option to check-in the file after it has been modified.

How can this be solved?

Rove answered 5/5, 2011 at 14:18 Comment(3)
Subversion or Git (and maybe others) are comparing hashes of files instead of API to check in/out a file. Far more simpler, and far less risky !Haftarah
worse TFS doesn't even noticed a changed file needs to be checked in, so you can often forget it.. until your colleague checks it out and realises your code doesn't compile or work. No wonder people say TFS is "VSS on steroids" - better, but still got many of VSS's problems.Exploitation
It's VSS on steroids, in the same way that steroids destroy your body.Urita
S
48

If you have a network connection to your server while you're working outside of Visual Studio, it's probably best to go ahead and check the file out before editing it, either using the tf command line client, or using the Windows Explorer shell integration that's available in the TFS Power Tools release. (Plus an increasing number of other tools have TFS integration that makes this automatic, but if you're just using notepad, this still needs to be a manual step.)

Of course, there are many times when you're working and you don't have a network connection available that allows you to check out the files.

If you know what files you've modified, you can just check them out from within Visual Studio, then you'll be able to check them back in.

If you don't know what files you've edited, you can detect the changes by running the tfpt online command (also part of the Power Tools release). This will locate the files that have been modified locally and check these files out from the server.

Safari answered 5/5, 2011 at 14:46 Comment(1)
Visual Studio doesn't seem to detect changes to files just by checking them out. I just tried checking out a folder and the contents showed up in pending changes as edits. Then I deleted the folder in File Explorer and refreshed the pending changes but Visual Studio didn't say the files were deleted in pending changes. Also, the files were still present in Solution Explorer.Bushel
Q
175

TFS has a "Reconcile" command for this:

  1. Open the Source Control Explorer
  2. Right-click on the folder with the changes and choose Compare
  3. Select the files you want to reconcile (press CTRL+A to select all files)
  4. Click on the Reconcile button
  5. Set the options in the Reconcile Folder Differences dialog. Make sure Files that do not have pending changes is set to Check Out
  6. Click OK
  7. If you have local changes the Check Out dialog will be shown. Set the preferred Lock type
  8. Click Check Out

Reconcile Folder Differences

See also: Reconcile differences between folders

Quipu answered 4/4, 2014 at 10:48 Comment(15)
This is the best answer as it does not require the command line or a risky 'Undo pending changes'.Amphistylar
Saved my day! I followed your steps precisely and it worked exactly as expected. :-)Hemispheroid
Worked as described. Should be the best answer.Gal
Unfortunately, when doing this over my whole project, I get the error The specified path, filename, or both are too long. The fully qualified name must be less than 260 characters, and the directory name must be less than 248 characters. Selecting individual folders is not an option for me, because I cannot remember all the files directories that I have changed. Any idea?Intumesce
@kraftwer1: Try moving your workspace to a folder with a short name in the root of the drive (for example C:\TFS)Quipu
I'm afraid you need to tweak your folder/path structure first then.Quipu
Working perfectly in VS 2015 update 3, thanks a lot. Should be the best answer, no tricky commands to make it worksGarret
Why no the delete command for the files that on server only (not in your workspace) ?Rabiah
I now have over over 750 marked changes instead of 15 or so, not sure how this worked for everyone? I can't check this in and have to dig through and undo changes on almost everything!Atencio
Why does it lack the option "replace server version with local version" ... incredible crap.Hone
Using VS2017, I no longer have a Compare option when right clicking a folder. This only seems to be available on files.Njord
@MyNameIsKo: learn.microsoft.com/en-us/vsts/tfvc/…Quipu
@Atencio I had same issue, but you can filter solution changes in Team explorer. 1. exclude everything. 2 in Exclude Changes tab change view options to "show solutions changes". Hopte that helpsIndore
"Compare" still didn't detect that I had deleted one of my local folders. It just noticed that the folder and its contents were checked out for editing. The "Reconcile" button along with most of the other buttons were grayed out.Bushel
VS-2019 Does not seem to have reconcile... PowerTools appear to be gone in the new world of Azure DevOps....Had
S
48

If you have a network connection to your server while you're working outside of Visual Studio, it's probably best to go ahead and check the file out before editing it, either using the tf command line client, or using the Windows Explorer shell integration that's available in the TFS Power Tools release. (Plus an increasing number of other tools have TFS integration that makes this automatic, but if you're just using notepad, this still needs to be a manual step.)

Of course, there are many times when you're working and you don't have a network connection available that allows you to check out the files.

If you know what files you've modified, you can just check them out from within Visual Studio, then you'll be able to check them back in.

If you don't know what files you've edited, you can detect the changes by running the tfpt online command (also part of the Power Tools release). This will locate the files that have been modified locally and check these files out from the server.

Safari answered 5/5, 2011 at 14:46 Comment(1)
Visual Studio doesn't seem to detect changes to files just by checking them out. I just tried checking out a folder and the contents showed up in pending changes as edits. Then I deleted the folder in File Explorer and refreshed the pending changes but Visual Studio didn't say the files were deleted in pending changes. Also, the files were still present in Solution Explorer.Bushel
C
35

This worked for me, using the TFS Power Tools:

tfpt online /adds /deletes /diff /noprompt /recursive directory-name

(where directory-name is the path to the directory to be updated, otherwise it will detect changes throughout your entire TFS repository)

If you want to know what it would do without it actually making any changes, you can force it to do a dry run by adding the /preview switch.

Complicate answered 13/9, 2012 at 15:5 Comment(6)
Thanks for the tip @Adam Batkin. Worked like a charm and I'm now fixed up! +1Swatow
Beware, this command line will also include unwanted files: *.user, BIN\, obj, etc...Haftarah
Cheers, I was looking for a command line way so I can automate updating the company's TFS from my local Git repo!Princessprinceton
@SteveB there is a /exclude:fld_name/*,filename switch that can be used for excluding unwanted files .. that halped me alotHinton
I run like this tfpt online /deletes /noprompt /recursive directory-name and got thousand files to be `changed`, so have to undo. But I never ever touched these, just deleted folder.Urinary
Running tfpt uu /noget after this will undo unchanged files too ;-)Ebullience
H
16
*1- make changes outside of Visual Studio
2- go to Visual Studio and open Source Control Explorer
3- right click on the folder > "Check Out for Edit" > "Check Out"
4- right click on the same folder > "Undo Pending Changes..." > "Undo changes" > "No to All"*

I tested this workaround on a branch and it helped me a lot. But there are only new files and new folder who has to be done manually.

I recommend to create a branch before the operation. It isolates you the time of the operation.

Note: This technique does also the files identical cleanup that TFS always marks as modified.

Hardset answered 27/1, 2012 at 18:24 Comment(6)
This should really be a comment on alga's post, not a new answer. In any case, I'd still recommend against doing this for the same reason I recommended against it when alga suggested it above.Safari
Utterly brilliant ! Exactly what I was looking for (after our company moved our TFS server, and TFS/VS2010 were baffled by it). Now, I just have my edited files checked out. Thanks!Revocable
This works, but MS should provide better ways to do this. Command line and hacks should not be necessary on a good product (especially if this is embedded into VS). SVN and Mercurial do this for fun...Georgeanngeorgeanna
Instead of point 4, you could use tfpt uu https://mcmap.net/q/136241/-tfs-how-can-you-undo-checkout-of-unmodified-files-in-a-batch-fileSelie
This just undoes what you did. It doesn't make Visual Studio aware of what you did.Bushel
This seems worth noting, when I did this, TFS showed all new changes in existing files but did not pick up any newly created files.Globoid
G
7

Try this. It's some sort of workaround, but it works:

  1. make changes outside of Visual Studio
  2. go to Visual Studio and open Source Control Explorer
  3. right click on the folder > "Check Out for Edit" > "Check Out"
  4. right click on the same folder > "Undo Pending Changes..." > "Undo changes" > "No to All"

That's it. The changes are visible now.

Grist answered 5/5, 2011 at 15:5 Comment(3)
I'd really recommend against this - my biggest worry would be that I'd fat-fingering this one and accidentally undoing all my legitimate changes. In addition, you're checking out all the files which, depending on your client and server configuration, will probably take a lock on some or possible all files and could do a get latest on check out which could certainly be annoying.Safari
This just undoes what you did. It doesn't make Visual Studio aware of what you did.Bushel
And if you created or added new items, in that session: Gone baby, gone!Incardinate
R
4

There's also another solution to get TFS to figure out the files that have changed outside of Visual Studio:

  1. Open the solution offline
  2. In Solution Explorer select the solution file and then press the Go Online button (GoOnline Button Icon)

TFS will automatically scan the solution for changes after this.

Step one can be achieved in a number of different ways. Here are some:

  • Use the GoOffline Extension - very simple and effective.
  • If you're asked for TFS credentials when opening the solution (no automatic domain auth), then don't enter the credentials. The solution will open offline and you'll login after pressing the Go Online button
  • (extreme solution) Disconnect your network cable; Open the solution; Connect the network cable.
Roe answered 8/9, 2012 at 20:32 Comment(1)
Worked for me, I made changes while TFS was down, and after it came back I had to press Go Online on the solution file to force-recognize the changes. ThanksStruble
S
2

Visual Sourcesafe works like this too and the way I get VSS or TFS to notice the change is by checking the file out once inside Visual Studio.

Supertax answered 5/5, 2011 at 14:32 Comment(0)
H
1

Open Source Control and go to your TFS folder. Right-click on the folder and choose 'Compare'.

Notice that your edited files show up marked in red.

I find this is better than tfpt online which also gets you files that are not readonly and not edited.

Hua answered 11/7, 2013 at 12:40 Comment(0)
E
1

I had this problem in the past, when my Internet was down and I worked offline, and most of my changes didn't appears in Team Explorer.

Following these steps: First, In the solution explorer, select the folder that you want to re-conciliate (for me, it was my entire solution folder), and select Compare... enter image description here Click in Modify Filter, and in the filter text-box, you could type:

*.cs;!obj\;!bin\;!packages\;

In this example, it will include in the search only C# files and exclude in the folders: bin, obj and packages.

Notice the column Pending Change has the info whether the file is marked as edit, add, etc... or nothing...

  • To mark as edit (when the local item has a matching server item), select the file and choose Check out for Edit...
  • To mark as add (when the local item doesn't have any server item), select the file and choose Add Files

Finally, I am not sure why the projects are not listed here (after I remove *.cs filter, still doesn't show up), so rebuild the solution to make sure the projects updates as well

+ In the solution, click the connect button (if shows up) that said Go Online.

Evangelicalism answered 23/7, 2015 at 15:3 Comment(0)
O
0

I found that in Visual Studio 2015, with the project open, Visual Studio discovered for itself that files had been modified externally, and automatically checked them out without me having to do anything. Checking in the project in the normal way saved the external modifications.

Outmarch answered 15/11, 2016 at 12:43 Comment(0)
D
0

In my case, the following worked (at least the one time I tried it):

  1. Go to the Pending Changes panel
  2. Select View Options under either Included or Excluded changes.
  3. Switch between Show All and Show Solution Changes
  4. Switch back if desired

Refresh TFS Changes

Changing the View Option appears to force a refresh of modified files.

Dannettedanni answered 6/7, 2020 at 14:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.