Let’s say branch A is a created from trunk. The branch A is in testing stage. Now there is a new project and will be release after branch A. However the project must start and cannot wait the branch A to be released. There is a big change in branch A and branch B is a few changes. I want to create a branch B from branch A. When branch A is release, it merge to the trunk. After branch B is completed and released, the branch B merge to the branch A and then Branch A merge back to trunk. Is it possible in TFS to merge trunk as the above approach?
TFVC branches are hierarchal. You can do a baseless merge, but that typically indicates a failure in your branching strategy.
The "modern" approach is to minimize the number of branches you create (or eliminate branches entirely) and instead rely on feature toggles to isolate work-in-progress, so that your codebase is always integrated.
Related
I have created a branched copy of my main production code-base so that I can safely perform development.
This involved creating a Main branch (the parent) and then another branch on the same level for my development called Dev(the child).
I have managed the merge the content from my child branch to my parent branch.
However, when I try and merge from my parent branch to my non-branched Production code base, I encounter problems.
I have attempted peforming a baseless merge using the Developer Command Prompt for Visual Studio 2017 Professional edition.
Do I need to do anything else such as converting my Production Code base to a branch. Then to re-parent the main branch and choose the new Production Code base branch as a parent, and perform the remaining merge that way ?
Is that the best way to accomplish my final merge ?
First, if your Production Code base are still folders not a branch. You should convert them to a branch first.
In TFVC, you could only merge to directly related branches(parent or child). There is no merge relationship between main branch and new Production Code branch in your case . You have to perform a baseless merge through tf merge command.
tf merge /baseless <<source path>> <<target path>> /recursive
/baseless
Performs a merge without a base version. That is, allows the user to
merge files and folders that do not have a merge relationship. After a
baseless merge, a merge relationship exists, and future merges do not
have to be baseless.
Note Baseless merges cannot delete files in the target. You can manually carry over such changes.
If you want to reparent to other branch, you must set a relation ship between the 2 branches first.
In other words, you still need a baseless merge first. Afraid, we could not take away the need for a baseless merge. As for how to reparent branch in TFVC, you could refer my answer in this link: TFS reparent to be a grandchild
I would ask you if you have some experiences with merge by tf.exe. I have two branches - branch 1 and child branch branch 2 created from branch 1. I have some changesets in branch 2 and I want to merge it to branch 1 (reverse integration). I merge it by tf.exe (my external tool call it). Then I want to show merge candidate from branch 1 to branch 2 (forward integration) and there are changesets created by previous merge from branch 2 to branch 1.
I compare branch 2 and branch 1 after merge from branch 2 to branch 1 and there are no differences. But I have still changesets in branch 1 which want to merge brachn 2. When I would merge these changesets from branch 1 to branch 2 (forward) then there are conflicts in resx files.
When I merge these changesets from branch 2 to branch 1 by Visual Studio there are not changesets to merge from branch 1 to branch 2.
What is different? I use my external merge tool because of create some reports of merged changesets and some reason of planning and releasing.
I found some related topics but there was about renaming of branches. But I have stable naming branches. Problem is when I do forward integration because this changesets do problems in merge.
We have release branches that are branches off of main.
We also have experimental branches that are branched off of main.
We now have a feature in one experimental branch that we want to add to another experimental branch.
The problem is that we don't want to merge those changes into main yet because then it would go out in a release sooner than planned.
What is the best way to accomplish this? Baseless merge? Should experimental branches not be merged off of main?
If you only worried about the planned release, you could use labels as a workaround. The difference between label and release branch you can refer this question:In TFS, should I label or create a branch for a production release?
As for should experimental branches be merged off of main or not, it's based on the useage of your experimental branch. If you branched what you needed from the main branch into an experimental branch. After some changes on experimental branch, you want to apply the changes to main, then you should merge back into main. If you fininshed the work and will work on another one, then you don't have to merge off of main and you could orphan this branch or delete it.
If you really want to perform this type of merge you can through something called a baseless merge. You could run it in UI with VS2012 and up or runs from the tfs command prompt:
Tf merge /baseless <<source path>> <<target path>> /recursive
I've the following structure on TFS:
$Base
- $Dev Branch 1
- $Integration Branch 2
I would like to merge the changes on Dev Branch 1 to Integration Branch 2 so that build guys can kickoff Hudson build of this Integration Branch.
I'm using Visual Studio 2008 Team, and when I try to merch Dev Branch1 I can only see Base on Target Branch drop down.
Could anyone please advise how and if it's possible to merge between Dev and Integration branches above.
Thanks
There are a couple of ways to do this but neither are that great. For the first method you will need to install the TFS 2010 power tools
Use a shelve set. Start the merge from dev to base, resolve any conflicts. Do not check in the merge, instead shelve the changes. Then from the command line use tfpt unshelve "my shelve set" /migrate /source:$/teamProject/dev /target:$/teamProject/integration. This will migrate the shelved changes to the integration branch without having to commit the changes to the base branch.
Perform a baseless merge between dev and integration. You can do this by using the command tf merge $/teamProject/dev $/teamProject/integration /baseless /recursive once the baseless merge has established a branching relationship then you can do further merges through the UI. Be warned though that a baseless merge won't know about any files or folders that have been renamed or moved so you will need to make sure you take this in to account.
Personally I'd go for option 1 if it's a one time thing. If it's going to be something you think you'll need to do regularly then I'd do the baseless merge when all 3 branches are in sync I.e. just after you've merged from dev to base to integration. This should minimise any issues with the baseless merge.
You might also want to take a look at your branching strategy so that you don't need to perform complex merging operations very often. If you use an integration branch then it should have a direct relationship with any branches you need to integrate. Check out the ALM rangers branching guidance.
You can only merge to where the branch was created from. You would have to merge from Dev to Base and then again from Base to Integration.
If you want to merge from Dev to Integration directly then your Integration branch should be created as a branch from Dev not Base.
Here is my current setup. (TFS2008)
I have a TRUNK with latest.
I have BRANCH-A off of TRUNK with only the production ready code merged in.
I would like to create a new BRANCH-B off of TRUNK but I don't want all the latest code, I only want what is currently in BRANCH-A.
After this is done I will be merging into both BRANCH-A and BRANCH-B from the TRUNK (so I don't want to branch BRANCH-B off of BRANCH-A.)
Thanks.
You need to perform a baseless merge. This sibling situation that you want to achieve is exactly what is described in How To: Perform a Baseless Merge in Visual Studio Team Foundation Server:
The process of merging items that are not directly branched from each
other is called a baseless merge. For example, you might want to merge
a change between two release branches, which are siblings of each
other, without merging up to the parent branch. You can only perform a
baseless merge by using the Tf merge command. You cannot perform a
baseless merge from within the Visual Studio IDE.
When you perform a baseless merge, TFS does not have any information
about the relationship of the files in the branches. For example, if
you have renamed a file, this will be viewed as a deleted file and a
new file will be added in the branch. For this reason you have to
perform more manual conflict resolutions than when you perform a
normal merge. However, you only have to perform this conflict
resolution once. After you have performed the baseless merge, TFS
records merge history and establishes a relationship between the
folders and files.
When you create BRANCH-B, you can either choose latest or a specific date/changeset/label. Take a look when you created BRANCH-A and create the BRANCH-B from the same date/changeset/label. As long as you haven't made any changes to BRANCH-A, you can create B to match.
Also, if you haven't already, take a look at the TFS 2008 Branching guidance. There is some great information and uses a pragmatic approach.
For TRUNK
On Create Branch you have option as a "Branch from Version" - by default By Latest Version is selected.
Select By changeSet or By Date