TFS: Overwrite (ALL) local file or folder - tfs

I'm trying to get latest on Visual Studio 2017/Angular project on a another machine and hence getting latest all files. It is taking a long time to 'Overwrite local file or folder' individually. Isn't there a way to Overwrite All local files or folders with single click?

In Visual Studio, from the Source Control Explorer, open the folder you want to overwrite. Use Advanced..., Get Specific Version...
And check the option "Overwrite writable files..."
Optionally check "Overwrite all files", but that should not be required and can take up more time.
You can also do this from the commandline:
tf vc get $/project/path /recursive /overwrite /version:T
And optionally to overwrite all files even if your system thinks they are unchanged:
tf vc get $/project/path /recursive /overwrite /force /version:T
Alternatively, you can use undo pending changes to revert to the last checked-in version, or scorch to clear files that aren't even checked in:
tf vc undo /recursive $/Project/path
and
tf vc scorch /recursive $/project/path

Related

How to know the current changeset id TFS Visual Studio

I have this workspace on this machine that is not updated for some days. I want to know the latest changeset Id that exists on this machine.
Let's say the latest changeset that is checked-in is 8400. I want to somehow find the current changeset id of the workspace on this machine, that might be say for example 8329.
Yeah, the tf history command can achieve that.
For your convenience, you can simply copy below strings and save as a cmd/bat file, then run it directly to get the latest changeset ID under the specific directory within the local workspace. (In your scenario you need to enter the root path of your workspace)
ECHO OFF
SET "VSDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer" :: For VS 2017
:: For VS 2015: SET "VSDir=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE"
CD %VSDir%
SET /p LocalPath=Enter LocalPath:
ECHO.
tf history %LocalPath% /r /noprompt /stopafter:1 /version:W
ECHO.
PAUSE
Besides, you can also use the Version Control client API to achieve that.
For more information please refer to: How to determine the latest changeset in your workspace
You may use tf history command. Go to root workspace folder and:
tf history . /recursive /noprompt /stopafter:1 /version:W

Copy source files to other TFS

We have a TeamCity/Octopus setup that runs great for several projects.
A new client wants access to the source code during development. Is it possible to copy code from our TFS to an other TFS using TeamCity? It does not need to be real-time. Daily copies are OK.
Not sure if we should use TeamCity for this or if there are possibilities within TFS itself.
You could setup a daily build schedule and use the TFS command line utilities to transfer the files to another server. You'll probably get all kinds of sync issues along the way, unless you always take your own solution as the current situation.
Look at tf.exe, especially the workspace, workfold commands and add, delete, and optionally destroy. Complete the job with a tf checkin.
Process as follows:
Create a workspace on your source TFS server (or use the built-in workspace features in team city): tf workspace /new
Map the folders you want to share: tf workfold /map
Get the files to the machine that's doing the transfer: tf get /recursive
Create a workspace on your target TFS server: tf workspace /new
Map the folders you want to share to tf workfold /map to a new folder that's not mapped to the source TFS server.
WS2 delete the files in the target folder: tf delete * /recursive
WS2 Check in to make sure you won't get any conflict remotely: tf checkin /recursive
WS1 -> WS2 Copy the files from the first workspace to the second: xcopy
WS2 Add all files: tf add * /recursive
WS2 Checkin all files tf checkin * /recursive
WS2 & WS2 Delete the workspace: tf workspace /delete
(Optional) Delete the files in the folders of the deleted workspaces on disk.
PS: if you move to git, this all becomes a lot easier, since the distributed nature of git is kind of meant for scenarios like these.

TFS File comparison report tool

I often compare DEV and MAIN branches and would like to run a report to show these results. I manually run the compare and copy and past the results into excel. Is there a more efficient way to do this?
You can use the command line tool tf.exe to compare a visual representation of the differences between files in two server folders, in a server folder and a local folder, or in two local folders:
tf folderdiff sourcePath targetPath /recursive [/noprompt]
/noprompt option means tf folderdiff runs without displaying user
interface. The output is displayed in the Command Prompt window
instead.

How to remove Excluded Changes from 'tf diff' output?

To create a unified diff of pending changes, you can use the tf diff command like so:
tf diff /recursive /format:unified C:\Development\MyProjectDir > pendingChanges.diff
However, this will output a diff containing changes to files both in the "Included Changes" and the "Excluded Changes" sections of the Pending Changes window in Visual Studio. Is there any way to output a diff just with changes to files in the "Included Changes" section?
If you put the changes you want in a shelveset you can compare the shelveset to the changeset the shelveset is based on.
The updated command would then be something like (assuming you run it from the root of your workspace folder)
tf diff /recursive /format:unified /shelveset:MyPendingChanges . > pendingChanges.diff
Refer to the docs for more information

Can I completely force a checkin to TFS?

I need a way to force a branch in TFS to update itself to exactly match what is in the working folders. I need something that will delete files that are on the server but not in the working folders, add files to the server that are only in the working folders, and update the changed files by using the exact version that is in the working folders. I need this to be form the command line or the API’s and not a manually in the UI.
Does anyone know of any way to do this?
tf undo $/ /r
tfpt online /adds /deletes /diff /noprompt
tf checkin /comment:"synchronizing" /noprompt
Get tfpt here if you don't have it already: http://msdn.microsoft.com/en-us/teamsystem/bb980963.aspx

Resources