TFS merge change set to main branch - tfs

If a file has been changed by 10 different changesets, with different users for various changesets.
Then the user that checked in changeset 5, decides to merge his changes.
What will then happen to the changes in changeset 1 to 4? Will they automatically be merged?

TFS has two ways of merging (you can select either one in the TFS Merge dialog):
All changes up to a specific version
Selected change sets
In the second case, you can cherry-pick any change you want, without necessarily merging all other change sets.

Yes, TFS will merge all changes UP TO and INCLUDING changeset 5 automatically.
When you merge a particular changeset back to Main, you are effectively asking TFS to integrate all changes beginning from the previous baseline up to the changeset that you specify.

Related

Discard unwanted change set

I am looking for a way to discard some unwanted change sets using TFS. I have looked into this site and many other and know that we need to use
tf merge /version:C137~C137 branch1 branch2 /recursive
However, I store all my source code in TFS DEV environment, I normally check out the code from DEV to my machine, work on it then check it back in DEV, roll back, fix it then check it back in. This process create many different change sets that hang around and needed to be cleaned up. So when I use TF merge command which branch I have to specify DEV and ????.
Thanks for your help
The merge command applies changes from one branch into another. /discard option means does not perform the merge operation, but updates the merge history to track that the merge occurred. This discards a changeset from being used for a particular merge.
But according to your description, you don't use branches or merge. What you want is delete/destroy changesets. Unfortunately, you can't delete changesets in TFS by default, if you delete changesets, the version control may be defeated.
You can always work with the latest version, when you want to work on a specific version, you can use TF rollback command. This command does not remove the changesets from an item's version history. Instead, this command creates in your workspace a set of pending changes that negate the effects of the changesets that you specify.

What will happen if we merge the same changeset multiple times? - TFS

I have two branches: DEV and Main. What will happen if we merge the same changeset from DEV to Main branch multiple times?
This often happens in the case of a Partial Merge.
Sometimes these are obvious, e.g. You merge a change with 3 files, but revert 1, checking in only 2 files.
Sometimes I'm not sure why TFS things the whole change wasn't merged.
If you perform a track changeset of your changeset it should show as a partial merge.
Merging it a second time, should remove it from the list and bring over whatever was missing, sometimes this is just meta-data.
Normally when you merge changesets are only merged one time and they are removed from the merge list after. Our team tries to merge everything at once and after that your merge list is essentially empty. It is highly discouraged to cherry pick what changes you merge.

TFS move a changset forward in the same branch

We currently have up to 3 developers working in the same branch.
In Jan, I submitted changesets (say 100-110) that have since had some code overwritten by changsets (111-300) during merges from other team members. I'm now just getting back to my project and I dread having to manually re-type all that code.
I can identify the exact changesets I need.
Is it possible to "merge" these specific changesets into the latest version of the same branch?
You can merge the changes in the same branch.
GO TO Branching and Merging option and click on the merging option you can merge the changes by choosing change set, date or label.
Hope you get my words

Cherry-picking changesets after bulk merge into main

Let's suppose that I have three branches:
Main
+--Dev
+--Release
And several changesets in Dev: changeset 1, 2 and 3 and all three changesets affect some File. At some point I merge them all into Main and get changeset 4, that includes changes from all three changesets.
What should I do if at this point I have to merge changeset 2 also into Release branch? If I try to merge from Main into Release I'll have to merge changeset 4 and then manually include only necessary edits made on File. But in this case after checkin, TFS will mark whole changeset 4 as merged and will not offer it later for merge, despite the fact that changes from changeset 1 and 3 were not included.
I know I could have avoided this situation by merging each changeset from Dev into Main separately, but that's very tedious and doesn't seem like a right way.
I could also use baseless merge and go directly from Dev into Release, but that's something I consider to be an extreme measure.
Are there any other ways?
Sounds like you need feature branches. You could then just merge change set 2 into release. You can still do this after rebasing or cherry-picking change set 2 off of the common ancestor into a feature branch.
Git-tfs will help you do this.
Hope this helps

How do I merge a Work Item from 1 branch to another in TFS 2008

I can't seem to find an easy way of doing this.
We have a trunk, which has a particular set of Changesets checked into a Work Item in TFS. I want to exclusively merge the changesets in this Work Item into another branch.
Surely this can't be difficult?
TFS absolutely does support cherry-picking. However, the range of changesets you cherry-pick must be contiguous. If you need to merge a set of changesets that has "gaps" in it, you'll need to run Merge multiple times. If the merge operations end up touching the same files, you will probably need to Checkin between merges.
You should be able to do this in a normal merge by simply selecting the changesets you want.
Open Source Control Explorer window in VS
Right click on the trunk (the folder that the original branch was made from)
Select Merge
Select the target branch to merge to from the dropdown list (if it doesn't appear then you probably selected the wrong source directory)
Pick the "Selected Changesets" option
Hit Next
Select the changesets you want to merge
I'm not sure if there's a way to do it from the workitem itself.
You may want to look into this tool:
http://wicreator.codeplex.com/Wiki/View.aspx?title=MergeByWI
This can be quite difficult, because afaik tfs does not support what is sometimes called "cherrypicking", i.e. merging a few otherwise unrelated changesets into a branch. Tfs expects that you merge the whole branch up to a certain version, without leaving any changessets out. I'm afraid what you're asking isn't directly possible.
You could do it manually, but for a large number of changesets it will be painful. The "links" tab in the workitem contains all changesets ids that were associated with the work item - that could give you some help.

Resources