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

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

Related

how to remove TFS workspace mapping for another user

I am using Visual Studio 2010. Some months back I was using some 'ABC' TFS user to connect to TFS and mapped some folders on my local drive. Now my previous user 'ABC' is gone and I am allotted a new tfs user 'XYZ' to connect to TFS. So naturally I tried mapping some remote folder to my existing local folder and I got the following error.
"The working folder 'Some_Local_Path' is already in use by the workspace WORKSPACE_NAME:USER_NAME on computer 'MACHINE_NAME'"
I have tried removing the cache folder contents but the same error (C:\Users{UserName}\AppData\Local\Microsoft\Team Foundation\3.0\Cache).
I have also tried running the commonly found TFS command (tf workspaces /remove:*) to delete the caches for all worksapaces but still the same error.
When I try to edit my workspace, it shows source control and local folders for my current user 'XYZ' but what I want is to remove the folder bindings for my previous user 'ABC'. How can I achieve that?
You need to get your TFS administrator to delete the workspace if you have no access to the account.
You may be able to do it by calling "tf workspace" with the explicit user specified, but you need "manage other users workspace" permission. TF Sidekicks uses the same commands so would require the same permission. It is a TFS admin productivity tool.
https://msdn.microsoft.com/en-us/library/y901w7se(v=vs.100).aspx
You can use:
tf workspace /delete "WORKSPACENAME;PREVIOUSUSERACCOUNT"
I had a similar issue and could not install sidekick because I'm running VS 2k17.
I was unable to delete the workspace because it kept telling me it could not find the workspace.
tf workspaces /computer:* /owner:*
This would list all of my workspaces and the owners. So I would try
tf workspace /delete myWorkSpaceName;Bob Smith
TF14061: The workspace myWorkSpaceName;Bob Smith does not exist.
That is the exact workspace and owner name I was getting in the original workspace listing above.
The solution was to ask for xml format
tf workspaces /computer:* /owner:* /format:xml > c:\temp\workspaces.xml
(Note: Output to file is optional, but recommended)
This gives workspace owner aliases and one of them was a long name with a guid and the account email. This finally worked:
tf workspace /delete myWorkSpaceName;aabe3ec12-1254-4956-b1ee-3fb26506931e\bsmith#myDomain.onmicrosoft.com
It asked for a confirmation and finally deleted my orphaned workspace.
If you have administrative rights to the collection you can use the TF command located in the Visual Studio\Common7\IDE directory to do this without having to install another tool.
First list the workspaces associated with the user:
TF workspaces /collection:"http://tfsserver:8080/tfs/collection_name" /owner:owner_id
This will return the list of workspaces owned by the user and computer they are associated with
To delete a named workspace:
TF workspace /delete workspacename;owner_id /collection:"http://tfsserver:8080/tfs/collection_name"
First of all you need to install TFS Sidekick (you can download it from http://www.attrice.info/cm/tfs/) In installation phase choose Integrated with IDE mode
Then a new menu will be added to Visual Studio as below
Menus -> Tools -> TeamFoundation Sidekick
Then open workspace sidekick
Search for the 'ABC' user and then you can delete his workspace
Open Source Control Explorer(View->Other Windows->Source Control Explorer)
On toolbar pane there will be Workspace combo. Choose from that combo Workspacess..
Edit
Remove
1.First we will check the list of workspaces from VS 2015 Developer command prompt,
Ex - tf workspaces /owner:*
2.Now we will get the xml format from VS 2017 Developer command prompt which will have ‘owner id’ for the particular workspace,
Example 1 - tf.exe workspaces /owner:* /computer:ComputerName /collection:https://YOUR-TFS-URL.visualstudio.com /format:xml
3.We can now delete the workspace for the particular user,
Example 1- Tf workspace /delete ComputerName;email#email.com /server:"https://URL.visualstudio.com"
OR
Example 2 - Tf workspace /delete ComputerName;1e178c77-bb8b-6f05-bf99
/server:https://URL.visualstudio.com
(Where 1e178c77-bb8b-6f05-bf99 is ID of the workspace which you get from Step 2 XML format)
4.Again we will check the list of workspaces from VS 2015 Developer command prompt,
Ex - tf workspaces /owner:*
Steps to delete workspaces from the TFS server:
Open Visual Studio Developer Command Prompt.
Goto Program Files (x86) folder, depending on the installed visual studio select "Microsoft Visual Studio 12.0" folder. Here this I have selected it because I am having Visual Studio 2013 installed on my machine. Add this path in the command prompt. Add like
"cd C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE"
Note: If you have an access of the TFS server from the network then you can try it from any machine where Visual Studio has been installed or from the same TFS machine server if it has Visual Studio there.
Check a list of workspaces under specific collection. Type below command to get the workspaces under one collection.
cd C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf workspaces /server:http://{TFSServername}:8080/tfs/{CollectionName} /owner:*
In the above command replace {TFSServername} this with your TFS servername or the Server IP.
In the above command replace {CollectionName} this with actual TFS Collection Name.
How to remove workspaces under specific collection. Check below command for the same.
tf workspace /server:http://{TFSServername}:8080/tfs//{CollectionName} /delete “{workspacename};{owner}”
Replace {workspacename} this with "Workspacename” which is there in the list of workspaces.
Replace {CollectionName} this with TFS Collection Name.
E.g. tf workspace /server:http://{TFSServername}:8080/tfs//{CollectionName} /delete {Enter Exact Workspacename};{Enter ExtactOwnerName}
I had the same issue that after deleting the workspace using tf delete command, I was getting the error that the workspace was already mapped! Then I found out tf delete workspace command leaves the job incomplete so you have to also delete it from the cache manually as was suggested here:
https://community.dynamics.com/365/financeandoperations/b/dynamicsaxinsightbyanas/posts/d365fo-the-path-is-already-mapped-in-workspace
I end up in same issue after the person who setup Jenkins left our company. He had setup workspace and TFS checkout was using alternate authentication. As his credentials are removed from msdn, TFS checkout started choking.
Following LarryG's solution helped to remove the workspace. Only difference is, I just used the windows live ID of the person, who left the company.
tf workspace /delete myWorkSpaceName;windowsliveID

TFS 2012 Unshelve to different branch -> An item with the same key has already been added

I need help resolving the following issue:
I am attempting to unshelve code from the source branch onto a target branch.
I am using the following:
VS2012 RC
TFS 2012
VS2012 x64 Cross Tools Command Prompt
When I use the command prompt to perform the unshelve operation, the following occurs:
Shelveset details dialog gets displayed with list of change files.
Click Unshelve button.
Observe command prompt output: "An item with the same key has already been added."
I have downloaded ServicePack1 for power tools.
However, I have failed to resolve this issue.
I had the same issue and fixed it when I re-shelved the changeset from the source branch but chose not to preserve pending changes locally. After this the migration of the new shelveset ran smoothly.
(I also made sure I'd followed the below steps collected from other answers on this site)
Use a workspace that encompasses both source and target branches
Run the command from the folder mapped to the source branch
Check for quotes around any paths containing spaces
Deleting the cache in C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\4.0\Cache and restarting Visual Studio
I had the same error when using Visual Studio 2013 and the following command:
> tfpt unshelve /migrate /source:"$/Root/Solution" /target:"$/Root/Branches/Solution" "The name of my shelveset"
> An item with the same key has already been added
Research
Here's what I tried to fix the issue:
Clearing the Cache as per Andrey's answer
Try running the command from the Source -> Branch and Branch -> Source
My workspace already encompassed both source and target branches
Solution
Open up your equivalent of the VS2013 x86 Native Tools Command Prompt.
Check you have Team Foundation Power Tools installed:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\tfpt
Ensure you have 0 Pending and Excluded changes.
I had some Excluded changes which were detected but not added and this is what caught me out. Excluded changes should look like this:
Note: No "Detected: XX (adds)" - should not be visible
When you run tf status, you should see something like the following.
Either 1 change(s) for the .tfignore file or 0 change(s). Anything else will upset the merge.
C:\tfs\Root\Solution>tf status
File name Change Local path
$/Root .tfignore edit C:\tfs\Root\Solution.tfignore
1 change(s)
Ensure you are running the tfpt command from the source Solution directory
You should be now be able to successfully merge a shelveset from one branch to another.
Note on .tfsignore:
If you have a lot of pending changes that you don't want to undo for whatever reason, then
a modification to the .tfignore file is ok.
If this is the only file that you have left with changes, it won't brake the merge.
.tfignore reference => stackoverflow - How to ignore files/directories in tfs?
Try to undo all changes on Source and Target branch and then try again...
Try to delete all the files in the following folder and restart VS2012 (Source):
C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\4.0\Cache

TFS command line to get all mapping information of a specific workspace

I am trying get all maping information for a specific workspace.
When I try this command, it displays a dialog - which is not what I want.
tf workspace myworkspace
Is there a command that will get all the working folder information and output to the console?
The following command displays the working folder mappings for the workspace in the current directory:
C:\projects>tf workfold
If you want to list the working folder mappings for a different workspace, you can specify the /workspace:workspacename parameter.
C:\>tf workfold /workspace:My_Other_Workspace
You can manipulate the workspace mappings using this command also.
The following example maps the folder C:\DifferentWorkfold to the Team Foundation version control server folder $/projects/project_one
c:\projects>tf workfold $/projects/project_one C:\DifferentWorkfold
See Tf Command-Line Utility - Workfold Command on MSDN for more information
In TFS 2008 and TFS 2010, the command
C:\projects>tf workfold
would indeed display the working folder mappings for the workspace in the current directory.
However, for TFS 2012, this command no longer works.
Now, you just get an error message:
Unable to determine the workspace. You may be able to correct this by
running the command 'tf workspaces /collection:TeamProjectCollectionUrl'
If I knew the TeamProjectCollectionUrl then I wouldn't need to run the workfold command!

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.

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