Is performing a Get Latest mandatory before checking in in TFS so you do not overwrite/lose code?

前端 未结 2 1417
孤街浪徒
孤街浪徒 2021-01-06 00:23

There is a recurring issue in my team that is driving me nuts. People claim that some check-ins in Team Foundation Server are overwriting previous check-ins/existent code. T

2条回答
  •  悲&欢浪女
    2021-01-06 00:25

    I'd say doing a get latest is good practice, but not mandatory.

    If I have a file that I've been modifying, and there is a more recent version held on the server.

    • If I do a get latest, I would expect a conflict to be detected and I would be asked to resolve the conflict before my local file system is overwritten
    • If I try to check the file in without doing a get latest I would expect TFS once again to detect a conflict and ask me to resolve it.

    I've just tested this behaviour and this is what I see. I'm using TFS 2013 and VS 2013 with local workspaces. I'm certain that server workspaces behave in the same way.

    The 2 scenarios that I can see that wouldn't follow this pattern are

    1. The changes are in different parts of the file, so TFS attempts to auto resolve the conflict. I would expect this to be fairly safe and you would see both sets of changes.
    2. The people checking in the second version of the file are misunderstanding the conflict resolution screen and selecting "Keep Local Version" when being presented with the resolution options.

    I would say that it's safer to do the get latest, as you can build the code after resolving the conflict to make sure that you've resolved it without breaking the build, however if you have a strong CI process in place then this reduces some of the risk.

    Edit: This is the documentation for get latest which states

    Keep in mind that if you get an older version of a file, make changes to it, and then try to check it in, there is an increased chance that you will need to resolve conflicts before you can complete the check-in.

    And this is the documentation on check in, which contains the following when discussing the outcomes of trying to check in a change

    Conflicts block your check in. The system presents you with conflicts between your changes the latest version of the files on the server. .

    Second Edit: You might find the comments on this question interesting. For Info Edward Thompson was a developer on the TFS team before he moved to github

    Automerge is generally the same across all vendors, and there aren't any longstanding known issues there. That said, it may be helpful to turn it off (Tools -> Options -> Source Control -> Visual Studio Team Foundation Server -> Attempt to automatically resolve conflicts when they are generated)

提交回复
热议问题