TFS: Undo checkout from "merge, branch, edit" to "merge, branch" - tfs

I have following situation:
I have created some new projects in solution in one development branch in TFS
I'm now merging them into the main branch.
Architect has idea to merge two new modules into one.
I have moved the code files
Project files has already been changed within the merge.
These files have pending changes in form merge, branch, edit. I wan't to make this file merge, branch, delete but TFS won't do that because the file has pending changes. Is it possible to force the deletion or undo edit without undoing merge, branch?
I don't want to try the merge again and combine files from two shelvesets... Is there any possibility to modify the status of pending changes?

No, TFS does not support that.
You could "undo" the file and just pend a delete instead.
As best practice you shouldn't be making changes as part of a merge, you should just do the minimum possible to resolve the conflicts and get it to build (or not even that sometimes) and then make your required changes in a subsequent check-in. This makes it easier to see in the version control history what changes were made when - I very rarely look to see if a merge of a change is any different from a prior edit.

Related

Apply a changeset to a branch when directory has been renamed

I have made some changes in a branch which involve renaming the sub-dir a project's code files live in, and committed this branch. I was unaware that while I was working on my branch, another developer made changes to one of the source files in this sub-directory and committed this.
When I merged my branch, it didn't detect the other developer's changes and undid them silently, which we only found later. When I try to re-apply their changeset, it just restores the files in their previous location.
I can manually re-apply their changes since it's an isolated case, but is there actually a way I can apply a changeset in this scenario, tell TFS the two directories are equivalent or something?
In your scenario, you can use tf merge command from command line with /recursive keyword, as since there is no way to specify the old name of the source branch from the UI, but we can from the TF merge command line.

Merging a branch back in - every single file listed as modified

I have a branch created some time ago in TFS of our main trunk branch. I've periodically been merging trunk->branch to keep it up to date and now I'm ready to push back to trunk.
I have modified about 10 files in 3 projects, however when doing the merge TFS marks 7000 files as modified, seemingly every file in the branch. I can see that the files are nor modified in every case I check but I don't dare check them in without checking every file and clearly that's no good in this case!
In the Source Control Explorer view, all these files and folders are marked as "merge" in the "Pending Change" column.
Can I fix things somehow or do I need to undo the merge and manually merge only the files I know I actually modified, breaking the whole point of merging?
Reasons for this might be one of the listed items in Why are all files marked with 'merge' in TFS?
But there are other cases as well:
Another branch of the target branch had itself a branch that was renamed then merged to the child branch then that child branch was merged to your target branch;
There was a move or rename of your branch and it was rolled back (but you can see it in the changesets still);
The way I solved it was to do a merge using the "Selected changesets" instead of "All changes up to a specific version". Then in the following dialog, exclude the renaming attempts.
Once this is done, you will still have these changesets in the history bugging you for every merge, so you might want to discard them with "tf merge /discard".

TFS: Branch without check-in

I'm going to create a new (vc)project which will start as a copy of another project.
I want to have the possibility to simply merge changes between these two projects, although they are inside another big branch.
I want to do this by branching, but when I do branch from ui, the branch is created and immediately checked-in. I don't want to do this.
Is it possible to make pending change of type "branch" without checking-in?
Branches are created on the serverside so they are automatically checked in. I would recommend using 2 shelvesets and setting up a secondary workspace where you can merge the two shelvesets.

TFS merge changeset into file with pending change

I have a feeling this is a very stupid question, but I can't find the answer anywhere.
So we have a Dev branch and a QA branch. I merge a bunch of contiguous changesets from Dev into QA, and resolve conflicts. Now I want to merge in a later changeset, over the changes I just merged (not having checked in the changes from the first merge). No dice, says TFS:
The item $/My/Path/to/the/file.vb has an incompatible pending change.
What's its problem? Why won't it give me a merge conflict option to merge the new changeset to the files with the pending changes? I don't want to check in the first merge just so I can merge in another changeset.
TFS doesn't allow you to merge multiple non-contiguous changesets if the same file is changed in both of them. Your best option is to checkin the first set of changes, then do the merge.
I had the same problem. I did undo all the pending local changes and un-shelved the pending changes. It fixed my problems.
I was experiencing this same issue for a different reason and since I stumbled here for help I will give my solution.
I had a branch (branched_from_main) that was branched from main. I made changes to branched_from_main and checked them into the tfs repo. Then when I tried to merge branched_from_main back to main I was experiencing this issue. After looking into it for a while I realized that I had opened the main solution and built it. This meant that the solution now pulled down all of the nuget packages. Thus my main branch was considering the packages as pending changes.
So to fix the issue I had to reopen the main solution and undo those pending changes. Then I was able to merge branched_from_main back to main.
It is enough to check-in the folder that you are going to branch to.
In my case I created a new folder in my target branch and it was on the "Add" state (without check-in) and I had this same problem. After I checked in this folder it worked well.

Re-do a batch of changes

I performed the following actions in TFS:
Accidentally made some changes to a bunch of files in the trunk
Realized it.
merged the changes to the intended branch
rolled back the changes in the trunk (using tfpt rollback)
later, during the regularly scheduled forward integration from the trunk, I undid the changes in the branch.
How can I reapply the changes? There are three changesets and about 80 files in question.
A couple ways to do this, but probably the quickest here would be:
Check out the affected files (for edit) in the branch.
Get Specific Version from trunk for those files.
Copy those files to the appropriate branch directory.
Check in.
You could also consider rolling back the rollback changeset in the trunk and redoing what you did (minus the undo).
What I ended up doing was a forced merge:
tf merge /r /force $/source/trunk $/source/branch1 /v:C123~125
I will watch this set of changes carefully when we reverse integrate back into the trunk.
I also tried a tricksy workflow of using tfpt to rollback, shelve, and unshelve /migrate. Unfortunately the conflict resolution dialogue in tfpt unshelve is a bit lacking - missing things like default buttons and stuff, so I had to mouse-click half a dozen times or so per file. So I decided after a few files to try something else first.

Resources