tf.exe checkin does not find any pending changes - command-line

I'm trying a simple TFS 2015 checkin automation. I have a local workspace mapped to a local folder. In that folder, I added some files and deleted one. What I want is to checkin those changes
I run this command
tf.exe checkin <folder> /recursive
The result (unexpected) is "no pending changes"
If I run the following command
tx.exe status <folder>
I get the list of changes expected.
If I look in Visual Studio source code explorer, I cannot see my changes but if I try to add items in the TFS folder, I can see new files.
Can you help me to understand how I can automate this checkin scenario?
EDIT : based on this SO thread, it seems it is not possible to achieve this with local workspace. Can someone confirm?

You need to run "tf add" command to add these files into Pending Changes before run "tf checkin" command:
tf add * /recursive

Related

Checkin command in TFS is opening a Checkin window

I am trying to checkin and checkout items from TFS workspace using command line. I am able to checkout the folder abc using the command,
tf checkout abc /recursive
which is working fine. The problem arises when I use checkin command. The command I use to checkin is,
tf checkin abc /recursive /comment:"Checkin check frmo CMD" /override:"Override"
This opens a Check In - Source Files window in which I have to manually press Check In button and then manually press the Override button for TFS to checkin the files. How do I get rid of this manual intervention that is necessary to checkin the files?
Edit: You can find the screenshot of the window here
Add a /noprompt option in your command should do the trick.
/noprompt
Suppresses the display of windows and dialog boxes (such as the Check In dialog box) and redirects output data to the command prompt.
More details please see this tutorial use Team Foundation version control commands-Check In.

Automate creation of shelveset when getting latest in TFS

Since TFS get-latest operation is non transactional there is no way to abort merging code after issuing get latest. Both Git and ClearCase allows you to backout of rebase operation. So one way I came up with is is to create a shelveset right before I get latest so I can abort and retrieve my code if there's too many conflicts that I don't want to deal with immediately.
My question is is there a way to automate the creation of a shelveset when you do get latest, ideally overwriting an existing one if it exists (say with a hardcoded name "HEAD").
Running the following command will auto shelve current workspace files and get latest:
tf shelve "HEAD" /comment:"Autoshelve" /replace /recursive /noprompt&tf get
You can store it in a .cmd file under your project's root folder in the source control.

How to delete from TFS all files that are deleted from working copy?

I've manually deleted some files/folders in my workspace. How do I pend deletes for those items in my TFS workspace and get those deletes to be reflected in the repository (via command line or programmatic API).
You should be able to use the tfpt online /deletes command from the Team Foundation Server Power Tools. It will prompt you to "promote" any untracked local changes that not in the Server Workspace.
Deleting items within your working folders will not reflect the delete within source control. To delete the items from source control do the following:
Delete it from source control ui, do this by right clicking the item and deleting then committing the change.
Open VS Command line and run the tf properties command, example: tf properties /s:TFSServerCollection "$/FilePath/Filename.jpg"
This will let you retrieve the delete ID, for this example lets say the delete id 12345
In the same VS Command line window, run tf destroy command, example: tf destroy /s:TFSServerCollection "$/FilePath/Filename.jpg";x12345
Don't forget to add the 'x' before the delete ID. Press enter and it will prompt you if you want to delete the item. Say yes, and then press enter. Just be careful as tf destroy complete removed the item and/or folder from source control including it's history.
In Visual Studio 2012: These deletions will be detected, but listed in the "Excluded Changes" section. Open this list and click to "promote" the changes.
Deleted Files can be checked-in like regular changes, however - if you use Solution-Explorer to checkin, deleted files aren't included (because only files which are STILL in the solution are included in the changeset).
I ALWAYS do my checkins via the source-control-explorer - then deleted files are also included in the checkin (if those deleted files are below the source-control-folder you are checkin in)
Greetings
Johannes
P.S.: if you delete the files via windows-file explorer, they aren't marked as "deleted" in your working copy. ALWAYS use VS2010 to delete files (or alternatively the shell extension included in TFS Server-Powertools)

Recover deleted file in the tfs

I have a huge repository. A while ago a file with the name FooBar.xml was deleted from some unknown directory in the tfs. What would be the easiest way to find the file? There are thousands of directories in the repository, so manually inspecting each and every one looking for deleted files is not a feasible option.
From a Visual Studio Command Prompt use the command
tf undelete $/TeamProject/FooBar.xml /noget /recursive
This will undelete any files in the repository with the name FooBar.xml, and leave the undeletes as pending changes. If you can narrow it down to a particular branch or area of your repository that will speed things up.
You can then go though the list of pending undeletes, identify the file you want to keep and "undo" the other pending changes.

TFS command line check in

I modified some of files which is under TFS, saved changes and tried to checked it in with the following command:
checkin "filename" /override:"1" /noprompt /comment:"some comment here"
and get the error:
There is no pending change for "filename"
Does anybody knows what should i do to check it in successfully?
Solution:
If you modify a file not in Visual Studio, it is necessary to do checkout before checkin to avoid this issue.
Just a guess, but it sounds like tf.exe doesn't know which workspace to make this checkin operation on. Look at the documentation for tf.exe workspace and tf.exe workspaces