ChatGPT解决这个技术问题 Extra ChatGPT

Why doesn't TFS get latest get the latest?

Why Why WHY doesn't TFS's get latest work consistently?

You would have thought that feature would have been tested thoroughly.

What I have to do is, get specific version, then check both overwrite writetable files + overwrite all files.

Is my local setup messed up or you do this also?

The silliest thing I see is that "Get Latest Version" does nothing even when the local file has been deleted for whatever reason. I would have thought checking that the local file at least exists was a pretty obvious thing to do. But why it can't just compare the time-stamp of each file on the server with the time you last did a get (which could be stored somewhere locally) perplexes me.
This should be a comment.
This is sep/2020. I'm here for the very same reason as most. Get latest does not get latest. I DELETE the entire solution folder! Close down VS, clean out the bin, restart my phone. Opens sln file from the TFS Source control Explorer. Still I get files and projs not working/missing files.

N
NotMe

TFS redefined what "Get Latest" does. In TFS terms, Get Latest means get the latest version of the files, but ignore the ones that the server thinks is already in your workspace. Which to me and just about everyone else on the planet is wrong.

See this link: http://blogs.microsoft.co.il/blogs/srlteam/archive/2009/04/13/how-get-latest-version-really-works.aspx

The only way to get it to do what you want is to Get Specific Version, then check both of the "Overwrite ..." boxes.


This isn't correct. TFS "get latest" works exactly as advertised, as long as TFS knows about changes to the files. Get Latest only "screws up" when people go out and modify filed outside of the IDE without checking them out first. Then, TFS thinks you have the latest source on disk, and doesn't get it.
@Robaticus How does tfs 'get latest' advertised really. just as chris lively said before, him and everyone on the planet understands that 'get latest' get latest version which is not what tfs would do. you dont have to edit source outside tfs to mess it up. i have 2 workstation and working interchangeably and i just cant get the source sync. getting latest version is already a hassle with tfs and i cant imagine what merging would like.
@publicENEMY, I used to work with tfs on two machine an indeed it is a problem to source sync. You might need two tfs users for this...
Ugh! This is a pain. Visual Studio can easily get messed up and sometimes fixing it on the filesystem is the easiest way to go. Other source control systems like Subversion have windows explorer hooks and both that and the VS integration do a better job of monitoring changes. I miss SVN!
I agree with the author. I read "Get Latest Version" as "Get Latest Version From the Server" (where else would I be getting it from?). In VS2010 I did Get Latest Version and told I have the latest version, but if I do a comparison it lists the differences between the local and latest server edition. I'm OK with it not overwriting local work, but it should at least do a timestamp comparison and not mislead me with "You have the latest version". When I deleted the local version, Get Latest Version worked as expected.
S
Simon_Weaver

Sometimes Get specific version even checking both checkboxes won't get you the latest file. You've probably made a change to a file, and want to undo those changes by re-getting the latest version. Well... that's what Undo pending changes is for and not the purpose of Get specific version.

If in doubt:

undo pending check in on the file(s)

do a compare afterwards to make sure your file matches the expected version

run a recursive 'compare' on your whole project afterwards to see what else is different

keep an eye on pending changes window and sometimes you may need to check 'take server version' to resolve an incompatible pending change

And this one's my favorite that I just discovered :

keep an eye out in the the Output window for messages such as this : Warning - Unable to refresh R:\TFS-PROJECTS\www.example.com\ExampleMVC\Example MVC\Example MVC.csproj because you have a pending edit.

This critical message appears in the output window. No other notifications! Nothing in pending changes and no other dialog message telling you that the file you just requested explicitly was not retrieved! And yes - you resolve this by just running Undo pending changes and getting the file.


Thank you, your answer (Undo pending changes) worked for me.
Just make sure to undo just the changes on the file you really want to replace and not everything you're working on
@Simon_Weaver Thanks this solved my issue, it makes sense why it is happening still super annoying though.
R
Rowland Shaw

TFS, like some other source control providers, such as Perforce, do this, as the system knows what the last version you successfully got was, so get latest turns into "get changes since x". If you play by its rules and actually check things out before editing them, you don't confuse matters, and "get latest" really does as it says.

As you've seen, you can force it to reassess everything, which has a much greater bandwidth usage, but behaves closer to how SourceSafe used to.


n
noonand

It's hard to respond to a statement without examples of how it's not working, but it's crucial to understand that TFVC (in "Server Workspace" mode, which was the mechanism prior to TFS 2012) does not examine the state of your local filesystem. TFVC Server Workspaces are a "checkout-edit-checkin" type of system where this is by-design, an intentional decision made to massively reduce the amount of file I/O required to determine the state of your workspace. Instead, the workspace information is saved on the server.

This allows TFVC Server Workspaces to scale to very large codebases very efficiently. If you are in a multi-gigabyte code base (like Visual Studio or the Windows source tree) then your client does not need to scan your local filesystem, looking for files that may have changed, because the contract you have with TFS is that you will explicitly check a file out when you want to edit it.

You are expected to not mark a file as write-only and change it without explicitly checking it out first. If you go down this route, then the server does not know that you have made changes to your file, and performing a "Get Latest" operation will not update your local workspace, because you haven't told the server that you've made changes.

If you do subvert this mechanism then you can use the tfpt reconcile command to examine your local workspace for changes that you have made locally.

If you find yourself using "Get Specific Version" and selecting the "force" and "overwrite" options, then it is very likely that you are in the habit of bypassing all of the enforcements that TFS has implemented to keep you from hurting yourself, and you should probably consider TFVC Local Workspaces.

TFVC Local Workspaces provide an "edit-merge-commit" type of version control system, which means that you do not need to explicitly check files out before editing them and they are not read-only on-disk. Instead, you simply need to edit the file, and your client will scan the filesystem, notice the change, and present this as a pending change.

TFVC Local Workspaces are recommended for small projects that do not require fine-grained permissions control, since they present a much nicer workflow. You are not required to be online, and you do not have to explicitly check files out before editing them.

TFVC Local Workspaces are the default in TFS 2012, and if they are not enabled for you, then you should ask your server administrator. (Organizations with very large codebases or strict auditing requirements may disable TFVC Local Workspaces.)

Eric Sink's excellent book Version Control By Example outlines the differences between checkout-edit-checkin and edit-merge-commit systems and when one is more appropriate than the other.

The Professional Team Foundation Server 2013 book also provides excellent information about the differences between TFVC Server Workspaces and TFVC Local Workspaces. The MSDN documentation and blogs also provide detailed information:

Decide between using a local or a server workspace

Server workspaces vs. local workspaces

Team Foundation Server – Trying to understand Server versus Local Workspaces


Great, informative answer, but I'm not sure the "marking a file as write-only" answers the OP. I know I'm using Visual Studio (now 2013) to make all of my changes to *.cs files in an MVC .NET project, and when I fire up my laptop, "Get Latest" often leaves me hanging to the point I'm nearly cargo culting "Advanced >>> Get Specific >>> Latest >>> Overwrite" now. There's no outside-of-VS edit or checkin. VS finds the files I've edited and puts them into Pending Changes properly. I check them in with VS. I can't see anything that would be "hurting myself", yet get latest doesn't reliably work. ??
@ruffin You're saying that get latest hangs? That wasn't what I interpreted the OP's question to be. Does it ever finish? Are other operations slow, or just a Get? Is Get w/ Overwrite ever slow or just the usual Get Latest?
Nope, doesn't hang. I can Get Latest, and it appears to work (and work reasonably quickly), but the files don't change. If I do Get specific >>> Latest >>> Overwrite, just as @NotMe suggestions, the files "catch up". Likely red herring: Also occasionally happens with Shelfsets. Yes, my working paths are correct, or Get Specific wouldn't work, I don't believe.
I don't have a good suggestion here. I wish you would contact support if you have a longstanding problem that you believe might be a bug. Whether this is a bug or not, you should get resolution to this problem.
H
Hammad Khan

Team Foundation Server (TFS) keeps track of its local copy in a hidden directory called $TF.When you issue the "get Latest Version", TFS looks into this folder and see weather I have the latest copy or not. If it does it will not download the latest copy. It does not matter if you have the original file or not. In fact you might have deleted the entire folder (as in my case) and TFS won't fetch the latest copy because it does not look into the actual file but the hidden directory where it records changes. The flaw with this design is, anything done outside the system will not be recorded in TFS. For example, you may go into Windows explorer, delete a folder or file and TFS wont recognize it. It will be totally blind. At least I would expect there Windows would not let you delete this file but it does!

One way to enforce the latest copy is to delete the hidden $TF folder manually. To do that, go to command prompt and navigate to the root folder where you project was checked out and issue this command

rd/s $tf                    // remove $TF folder and everything inside it

If you want to just check the hidden folder, you can do it using

dir /ah                    // display hidden files and folders

Note: If you do it, the tf will think you do not have any local copy even though you have it in files and it will sync up everything again.

Caution: Use this method at your own risk. Please do not use it on critical work.


This worked for me when nothing else did. I tried get specific version and checked both checkboxes to force download, but that wouldn't get the files. I think something was corrupt. But this solution worked.
D
David

"Get latest version" by default will only download the files that have changed on the server since the last time you ran "Get latest version". TFS keeps track of the files you download so it doesn't spend time downloading the same version of the files again. If you are modifying the files outside of Visual Studio, this can cause the consistency problems it sounds like you are seeing.


Tell us HOW to reset this [last changed] info; instead of what we already know :) And you have helped OP to what no one else can figure out.
L
Lasse V. Karlsen

Unfortunately, there has to be one or more bugs in TFS 2008, since this problem regularly crop up on developer machines and build servers where I work as well.

I can do Get Latest, I can see in the history list of the project that there have been commits after I last did a Get Latest, I have not touched the files on disk in any way, but after the "Get Latest" function has completed, when I check the TFS tab, some of the files still says that they're not the latest version.

Obviously TFS is able to determine that I have old files locally, since the list says so. Yet, Get Latest fails to do that, get the latest version. If I do what you did, use the Get Specific version, and check the two checkboxes at the bottom of the dialog, then the files are retrieved.

We changed our build servers to always use the Get Specific version type of function instead, so this part now works, but since our build server (TeamCity) also relies on checking if there have been changes to the files in order to kick off a build, sometimes it lapses into a "nothing changed, nothing to see here, move along" mode and does nothing until we forcibly run the build configuration.

Note that I have experienced this problem on a machine that is never touched, except for get latest + build, both manually, so there's nothing tampering with the files. It's just TFS getting confused.

One time this cropped up I verified that the files on disk was indeed binary identical to the version previously retrieved, so no manual tampering had been done with the files.

Also, I fail to see how TFS can "know" whether files have changed on disk or not without actually looking at the contents. If one part of TFS can see that the files are indeed not the latest version, then the Get Latest version should absolutely be able to get the latest version. This in reference to comments to other answers here.


TFS depends on a files version number to know whether you have the "latest" version or not. That number is maintained entirely in TFS and is only updated when someone does a check in. So, when you "Get Latest", TFS checks it's database to see what the last version sent to you was. If this number is equal to the current version, then it believes you have the latest; regardless of what is actually on your local file system. The idea was to limit down network traffic. Unfortunately, the only way this model works is if all edits occur within an application that has knowledge of TFS.
Also, I agree there is at least one bug with 2005/08's version of this. I've seen the exact issues you've described on multiple machines; which is what lead me to use Get Specific version religiously.
In some of the cases, edits have happened entirely within Visual Studio on one machine, the other machine, which sole purpose is to do get latest + build, no local changes are being done, ever. Yet it manages to screw this up. I'm not impressed with TFS Source Control to say the least. Hopefully 2010 will have fewer of these problems.
W
WalkingCat

It might because you are login TFS as the same user, and the workspace name (based on machine name by default) is also the same, so TFS thinks your are on the same machine and same workspace, thus you already have the latest version of the files, so it wont get them for you.

try rename your machine, and create a new workspace as a new machine.


m
mjlarezzo

WHen I run into this problem with it not getting latest and version mismatches I first do a "Get Specific Version" set it to changeset and put in 1. This will then remove all the files from your local workspace (for that project, folder, file, etc) and it will also have TFS update so that it knows you now have NO VERSION DOWNLOADED. You can then do a "Get Latest" and viola, you will actually have the latest


N
Nir

I had the same issue with Visual Studio 2012. No matter what I did, it didn't get the code from TFS source control.

In my case, the cause was mappings a folder + subfolder from the source control separately but to the same tree in my local HD.

The solution was removing the subfolder mapping using the "manage workspaces" window.


A
Amira Bedhiafi

https://i.stack.imgur.com/faR7v.png

The checks are: Overwrite writeable files that are not checked

Overwrite all files even if the local version matches the specified version


Please describe the items that need to be checked rather than posting a screenshot.
dude.. Everybody in here is talking about this overwrite. Its exactly this method we cant trust.
l
levelnis

Most of the issues I've seen with developers complaining that Get Latest doesn't do what they expect stem from the fact that they're performing a Get Latest from Solution Explorer rather than from Source Control Explorer. Solution Explorer only gets the files that are part of the solution and ignores anything that may be required by files within the solution, and therefore part of source control, whereas Source Control explorer compares your local workspace against the repository on the server to determine which files are needed.


I tried it from Team Explorer, still the same result. In my case I deleted the folder and wanted to get the latest copy again but no luck.
I don't agree with this answer. If you have shared projects used by different solutions, you have to do it in Solution Explorer, otherwise it will just do a Get on that particular TFS path
Why add the option from Solution Explorer if you aren't supposed to use it? When I clicked "Show All Files" the file was there but not included in my project. Weird since I wasn't even the one who added it.
I tried get latest from Solution Controller, my file explorer and open as sln from TFS. DELETE the entire sln folder including the hidden tfs .vs folder? yeah. Tried that too :)
M
Mohamed Badr

It could happen when you use TFS from two different machines with the same account, if so you should compare to see changed files and check out them then get latest then undo pending changes to remove checkout


L
Ludwo

This worked for me: 1. Exit Visual Studio 2. Open a command window and navigate to the folder: "%localappdata%\Local\Microsoft\Team Foundation\" 3. Navigate to the sub folders for every version and delete the sub folder "cache" and its contents 4. Restart Visual Studio and connect to TFS. 5. Test the Get Latest Version.


H
Himanshu Patel

In my case, Get specific version, even checking both check boxes and undoing all pending changes didn't work.

Checked the work spaces. Edit current workspace. Check all paths. The solution path was incorrect and was pointing to a deleted folder.

Fixed the path and get latest worked fine.


E
Etherman

Every time this happens to me (so far) is because I have local edits pending on the .csproj project file. That file seems to keep a list of all the files included in the project. Any new files added by somebody else are "not downloaded" because they are not in my locally edited (now stale) project file. To get all the files I first have to undo pending changes to the .csproj file first then "get all". I do not have to undo other changes I have made, but I may have to go back and include my new files again (and then the next guy gets the same problem when he tries to "get all"...)

It seems to me there is some fundamental kludginess when multiple people are adding new files at the same time.

(this is in .Net Framework projects, maybe the other frameworks like Core behave differently)


b
bherto39

just want to add TFS MSBuild does not support special characters on folders i.e. "@"

i had experienced in the past where one of our project folders named as External@Project1

we created a TFS Build definition to run a custom msbuild file then the workspace folder is not getting any contents at the External@Project1 folder during workspace get latest. It seems that tfs get is failing but does not show any error.

after some trial and error and renaming the folder to _Project1. voila we got files on the the folder (_Project1).


TFS or not, you should never use special characters in project folder names!
@ is not special. And neither is %, etc, etc. It's just laziness on the part of Microsoft that causes such characters to be treated differently from 'normal' characters.
N
Nick

Tool: TFS Power Tools

Source: http://dennymichael.net/2013/03/19/tfs-scorch/

Command: tfpt scorch /recursive /deletes C:\LocationOfWorkspaceOrFolder

This will bring up a dialog box that will ask you to Delete or Download a list of files. Select or Unselect the files accordingly and press ok. Appearance in Grid (CheckBox, FileName, FileAction, FilePath)

Cause: TFS will only compare against items in the workspace. If alterations were made outside of the workspace TFS will be unaware of them.

Hopefully someone finds this useful. I found this post after deleting a handful of folders in varying locations. Not remembering which folders I deleted excluded the usual Force Get/Replace option I would have used.


ח
חרות

I encountered the same problem:

My development server was corrupted and restored, but the information restored was from a few days ago.

TFS was updated that all the files are up to date, but in practice my files were correct a few days ago!

Nothing I did helped. get latest did not get the latest version.

At the end I got specific varision from a month ago. my files were updated accordingly, and then I did get latest.

And it worked. the files have been updated.


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now