Recover deleted file in the tfs - version-control

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.

Related

Will a folder be deleted entirely if it was deleted in a git repository and the user selects "Discard all changes" in VS Code?

If a user selects to "Discard All Changes", will this restore a deleted folder in Git for the working tree or will it delete the folder entirely?
Issue resolved. I was concerned that if I ran the "Discard All Changes" command, my folder would be deleted entirely. I thought that was strange considering that if you visit a single file that was deleted in the folder, VS Code gives the option of restoring that file, but I wanted to undo the entire folder deletion. Since I didn't stage or commit the changes after I deleted the folder, I was able to revert the change in my working tree by running the following command:
git checkout -- path/to/folder
That command allows a user to revert changes that have not been indexed or added to the staging area.
I found this helpful
https://stackoverflow.com/a/30875442/10860528

Deleteing a repository in Visual Studio Code

where can I find .git folder to delete a repo on my system. I opened my local disk as a repository and I have about 5k changes to make.The thing is if I check my git account my local disk is not showing as a repo so i really dont know what is going on. Any solution will be welcomed.
Among the "5k changes", select a file and open it in your file browser. Enable hidden files/folders. Start moving up the hierarchy of that path, i.e., keeping going up in the parent directory of the file.
You'll find the .git folder somewhere. Check its creation date. If it's recent, delete it. Be careful not to delete any commits you had made in some project.

Restore deleted workspace in TFS to retrieve pending edits

I had edits on my local machine which had it's own workspace. I was given a new machine and I have setup a new workspace with my new machine. By mistake I deleted my old workspace while there were still pending edits associated with it. Now I lost all my pending edits. Is there a way to retrieve all my lost pending edits.
Please note that I still have access to my old machine. If I'm able to retrieve all my lost pending edits I can bring those files to my new machine and check-in those changes.
You should be able to do the following:
On your new machine use "Get Specific Version" to get the same source changeset (the last changeset you retrieved to your previous machine). Set it up as a Local Workspace, that way Visual Studio will detect changed files automatically as "Checked Out".
From your old machine zip up all the files
Extract all the files over the workspace on your new machine.
Wait for the local workspace to be consolidated (give Visual Studio some time to figure out which files have changed)
Use "Include in project" to add any files that you added on your previous machine.
Use "Get Latest Version", fix any merge conflicts, Build everything, Run your unit tests
Check in your code.
This will not detect deleted files, but modified/added files should be detected/added. You'll have to compare the list of file sin both systems to ensure all deletes are handled correctly.

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)