Can I completely force a checkin to TFS? - 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

Related

TFS: Overwrite (ALL) local file or folder

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

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.

unshelving team explorer everywhere

I'm trying to unshelve a shelveset using the command line with team explorer everywhere. I keep receiving this error:
An error occurred: TF400016: Unshelve with Merge is not supported on the version of Team Foundation Server on which your team project is hosted.
The shelveset is on the same branch as the one I'm trying to unshelve onto. I've run tf undo -recursive . before trying to unshelve and it tells me there are no pending changes, so I'm unsure why it is trying to merge. Has anyone had any success with this? Thanks for the help.
Has the file changed in tfs since the shelve set was created? I have seen the same problem if you try to unshelve a set from previous version of the file over a subsequent version. To resolve, you can pull the code that matches the shelve set, then unshelve, then get the latest code and the merge will happen correctly.

tfpt migrate for TFS doesn't do anything

I'm trying to use tfpt to migrate a shelveset from a source branch into a target branch, but it doesn't appear to do anything...not that I'd expect much more...but any chance anyone knows what's wrong? I'm following the instructions correctly I think...
I've got:
tfpt unshelve "DbMigrations" /migrate /source:$/TeamProject/Main /target:$/TeamProject/Releases/7.20
What happens after you run the command? You need to have a few things set up before migrating:
A workspace that encompasses both the source and target branches.
You need to run the command in a folder within the source.
Once you run the command you should be asked to merge the changes from the original shelfset into the destination branch and resolve any conflicts, which finally pends a changeset on your client. Nothing is touched on the server until you check that changeset into TFS itself.
I experienced the same problem and I could not get it to work by specifying the shelveset name. However, I discovered that if you remove the name of the shelveset altogether, TFS will pop up a window with a selection list of available shelvesets to choose from. Select the desired shelveset and perform all other merge operations as per normal.
Example: c:[mapped workspace target path] > tfpt unshelve /migrate /source:"$/Sourcepath" /target:"$/targetpath"
You need to use the branch paths on the TFS server, not your local machine. To find the paths, go to source control explorer in visual studio, right click the branch, advanced > properties, and you want the branch name, not the local path. If the path has spaces, wrap it in double quotes.

TFS: How to find untracked files in a TFS workspace?

Is there any easy way to list all untracked files in a TFS workspace, like what "git status" reports in the "untracked files" section, or the output of the following command:
git ls-files --other --exclude-standard
TFS PowerTools works for me! I also find I can get the same result with the following command:
tfpt treeclean /noprompt /preview /recursive
TFS PowerTools can do that
http://msdn.microsoft.com/en-us/tfs2008/bb980963.aspx
After installing it, from the command line try:
tfpt online
In Visual Studio IDE, in Source Control Explorer, right click on a folder an choose "Compare". This will allow you to compare local folder with your source control folder. There are various options there as well like ability to show or hide items that exist only on one side, exclude files by extensions, etc

Resources