How can I migrate files to another branch without checking them in? - tfs

tfpt.exe is not exist anymore from VS 2017 and beyond. So how can I move files from one branch to another without checking them in. Say I've accidentally written code in the wrong branch or I'm told to move my change to a different version before checking in. This happens all the time. If there is not a way to do this, then either TFS is broken or I'm using it wrong.
This no longer works:
tfpt unshelve /migrate /source:"$/MyProject/DevCurrent/DevMain" /target:"$/MyProject/DevNext/DevMain" "Temp"
Please don't mark this question as duplicate without making sure it actually is. I've been researching this all day, and there have been 15 million different ways of doing this over the past ten years none of which work on modern tooling.
I need a solution for TFS 2018 and Visual Studio 2017. I do not have control over these versions.

After I had the same problem with VS2019, my best way to to it was to copy/paste the modified source folder to the branch target folder and use
tf reconcile /promote
to detect all added or changed files.

This happens all the time.
Why? it shouldn't happens all the time. check where you are and then start coding.
I've been researching this all day
So I guess you see this question, if the answers there not good for you, let me suggest a simple way to do that, but it's manual way and not just run a command:
1) You change a file and suddenly you put attention that you are in the wrong branch.
2) You don't want check-in the changes to the wrong branch.
3) In the past you put the file in Shelveset and then tfpt ..., but now the command no longer exist.
3) No problem. Go to your local folder, copy the file (with the changes).
4) Go to the correct branch local folder and paste the file there.
5) Go to Pending Changes and "Undo" the changes in the wrong branch.
6) Check in only the file in the correct branch.

Related

Merge changes from TFS to local copy of same branch (master)

Apologies if this is a stupid question, but ...
We are a very small team (3) working all on the master branch from TFS, making local changes, then checking them in (and if necessary merging). The bit that puzzles me is how to merge changes down from the server to my local copy BEFORE checking in. I am sure it something really simple that I have missed/forgotten about this particular scenario in TFS.
Can anyone remind me?
In TFS you just do a "Get Latest" in Visual Studio.
If you're working on the command line you can:
cd \Code
tf get . /recursive
Or just tf get (depends how you're workspace is mapped).
If there is a conflict between a local change you have made and a change your colleague has checked in on the server, TFVC will attempt a merge, and if it cannot be resolved, will mark the file as a conflicting change for you to resolve.
TFVC also does a get latest of any file you attempt to check in before you are allowed to check in, forcing a merge at this point too. This can be quite confusing if someone has changed many files and yourself only one, as the get latest will only be for the one you changed, in those cases I usually get everything again.

How to partially undo a TFS checkin across multiple solutions

A while ago, I accidentally checked in some unfinished unittest files I had changed and added in solution A together with some files that contained an actual bugfix for project B.
For some unknown reason I never noticed the checkin was going to include files from another solution so the checkin was done, after which other team members added more checkins to both solutions.
My question now is two-fold;
How can I undo the part of the checkin that hit solution A without affecting B at all
Is there a way to prevent mistakes like this from ever being possible to happen within Visual Studio (Enterprise 2015), make it impossible to checkin files not part of the currently opened solution somehow?
I think the easiest solution would be to use the ROLLBACK command, if you have installed the TFS power tools (TFPT) you should be able to do it within visual studio.
In your current branch, get the latest version from server then view history and find your changeset. Then right click and select "Rollback entire change set".
This will rollback the changes in your local workspace and checkout the file. (If there are conflicting changes you will have to resolve conflicts.)
Now when you are ready to check-in, exclude/undo the files which you don't want to rollback.
Commit/checkin the files which you want to rollback.
I haven't seen a better way of doing this, and think that this is much better than individually rolling back each file in the change set.
Now to answer your second question: check this ANSWER which I wrote a while back. I am copying it here for convenience.
As far as I tested, this default setting is controlled by the following registry entry. If the value of this registry entry is set as 1, then it should change the default behavior to filter by "Solution Changes".
"HKCU\Software\Microsoft\VisualStudio\12.0\TeamFoundation\SourceControl"
Name: FilterPendingChanges
REG_DWORD
Value: 1 = Show Solution Changes
Value: 0 = Show All

How to get the files that were changed in a changeset in tfs

I was looking through a changeset in tfs and it has more than 6000 files in changeset but when I check the files individually almost each file included in changeset was indentical to the previous version. Is there a way I can find what files were really changed through the changeset in tfs?
this is an old one, see this post. you have to be a little bit brave, so try it somewhere safe first.
specifically:
Another option is to “Undo Checkout” all the changes, and clicking “No to All” when asked to confirm for undo checkout. This way Visual Studio will “undo checkout” all the files that are not changed, and all the changed files will remain checked out. I always use this method.

TFS / Merging a missed check in

Yes this is one of the Doh! Damn! I shot myself in the foot. I don't have a lot of experience with TFS in large teams, but I'm facing this issue.
During a transition to new equipment, a developer forgot to check-in some code. Work proceeded on the new laptop for several weeks before noticing that the previous work was not checked in. Mutliple check-in have occured.
I have recovered the files from the old laptop, and have them on my current laptop. What is the best way to merge in these changes? Do I create a branch, merge in these changes, and then rejoin the branch?
Is there a "cookbook" out there that details what should happen when faced with various situations?
We are using TFS 2010.
Thanks in advance...
Creating a branch here is probably a little bit heavier-weight than what you need for this one-off situation. If it were me, I would do this:
Set up a workspace on your computer with the appropriate mappings.
Do a Get Specific Version to the version that the other computer was at. The best case scenario is if the user never deleted their workspace on the server. Then you can simply specify their workspace as the version and you'll get the files as they existed on the laptop. (You can specify this as Wworkspacename;owner name.) If the user deleted their workspace, you can get based on the changeset number they were at, or based on the date they were working at.
Copy the recovered files on top of the new TFS workspace.
Run tfpt online from the Team Foundation Server Power Tools. This will examine the local filesystem against the server and determine what changes were made. You may wish to examine the options, notably the /diff flags (which performs MD5s on the file instead of simply examining the readonly bit), and the /deletes and /adds flags, which detect deleted and add files, respectively.
Do a Get Latest on your workspace, resolve any conflicts, and check in.
You can follow this sequence to try out:
Make a merge-branch of your code version based on the time-stamp of where your restored laptop code has left the version control system.
Get your branched code to a location on disk.
Perform a check-out for edit of the entire workspace.
Copy the old restored code over the files in this workspace.
Perform a checkin of the local code into the branch.
Merge your latest code (main trunk) into the branch, merging changes, solving conflicts.
If all build and tests out correctly on the merge branch, merge that branch back into the main.
That should do the job.

How to get a previous version of a file

I need to get a previous version of a file in source control, using Team Foundation Server (TFS), . When I try to get a specific version based on change set the merge screen comes up. I do not want this, I just want to get the previous version and have it checked out. My current version of the file got corrupted and now I just want the previous version.
Ah, it sounds like you want to rollback (that is, remove some checkins from TFS' history). There is not a built-in way to do this with TFS. However, you can use the TFS Power Tools to accomplish this (there is a tfpt rollback command).
In practice, the rollback command just does what you're trying to do. To do it manually, get the version that you want (without checking out the file). Save that somewhere else, then check the file out (which will perform a "get latest" command). Then overwrite that version with the version that you saved elsewhere.
Alternatively, there's a setting in the TFS settings to "Get latest version of item on check out," which may be the cause of all of your problems. It's located in Tools->Options, under Source Control->Visual Studio Team Foundation Server. If that's checked for you, try unchecking it and seeing if it'll let you do what you're trying.
On the merge screen, you should be able to choose to overwrite your local copy with the server version. That sounds like what you want to do.
However, the merge screen should only show up if you have pending changes. If you undo your pending changes on the file, the Get Specific Version command shouldn't cause a merge.
Hmm maybe I am doing something else wrong. I check the file out, then I do get specific version, enter the changeset number, I do not check either of the overwrite check boxes. I get the merge screen, I tell it to overwrite local copy. It does this, but then it undoes my check out and says I do not have the latest on my local computer. If I checkout at this point it ovewrites my previous version with the latest.

Resources