The get command retrieves items from the server into a workspace. If no other version is provided, the latest server version is retrieved.
If you work in a team development environment, Get is the command you use most frequently because getting every file in the current project synchronizes with your team and makes sure that you have the very latest copy of shared work. The get command does not overwrite files that you have checked out in the local directory. The more frequently you perform the get command in a collaborative working environment, the more current the local files are with that of your team. That is because a get operation populates the local workspace with changes that have been checked into the server by your teammates. If you keep your workspace up-to-date by performing a Get Latest operation whenever you see a check-in notification, you can quickly resolve differences between your version of a project and the server version of the project. You can avoid making changes that might not be easy to reconcile with the server when you check in your pending changes.
During a get operation, if your workspace version is the same as the requested server version, Team Foundation Server does not replace the file on disk unless the /all option is specified. You can use the /overwrite option to forcibly overwrite the writable current workspace version with a specified server version in order to restore your workspace to a consistent state when it becomes unmanageable, such as sometimes occurs when you delete or accidentally overwrite multiple files on disk or when your computer is infected by a virus. When you pass the /force option, Team Foundation Server overwrites all items in the workspace with the latest server version unless you provide a specific version.
When you perform a get operation, Team Foundation Server deletes any checked-in files from the local workspace that have been deleted from the server after the last time that you synchronized your workspace to the server version. Files that have been renamed or moved on the server are relocated on disk to match the changes on the server.
You can use the /preview option to issue the get command without making updates to the local workspace in order to see what would occur if you were to perform an actual get operation.
Note |
|---|
| Be careful when retrieving single file revisions into a workspace, especially if its timestamp differs significantly from other related workspace items. Workspaces that contain chronologically inconsistent file revisions can be more difficult to synchronize with the latest Team Foundation source control server version and when checked in, increase the chance that future check-ins can unintentionally introduce bugs into the build. |
Checkout operation does not perform a get latest operation on files being checked out
When you perform a get operation to populate your workspace with a set of files, you are setting yourself up with a consistent snapshot from source control. Typically, the configuration of source on the system is a snapshot of files from the Team Foundation source control server that are known to work together, and can be built and tested.
As a developer working in a workspace, you are isolated from the changes that were made by other developers. You control when you accept changes from other developers by performing a get operation as appropriate. Ideally, you can update the complete configuration of source and not just one or two files because changes in one file typically depend on corresponding changes to other files. You must make sure that you have a consistent snapshot of the source that can be built and tested.
Therefore the check-out operation does not perform a get latest on the files checked out. Updating one file being checked out would violate the consistent snapshot and could give you a configuration of source that cannot be built or tested. Alternatively Team Foundation Server forces you to perform the get latest operation at some point before you check-in your changes so that when you try to check-in your changes, and you do not have the latest copy, you are prompted with the resolve conflicts dialog box.