简体   繁体   中英

How do I merge a CVS branch into HEAD using the Eclipse merge tools?

I'm currently working in a branch I created using the Team-->Branch. How do I use Team-->Merge to merge my changes to the branch back to head?

I was having trouble with this too. Here are the steps I take to merge (mostly taken from the online Eclipse help):

  1. When making my development branch ( Team -> Branch ) I ensure I have a root tag created for the branch, this is the tag CVS will use to determine what changes are due to the branch and what might have been committed from other efforts
  2. I complete my development on the branch and commit ( Team -> Commit ) all changes back to the repository
  3. Now that all my changes for the branch are in the repository I load the destination branch that I want to merge into, typically HEAD ( Team -> Switch to Another Branch or Version )

You are now ready to begin the actual Merging process. Here you will be picking which changes should come over and which should be discarded. Think of this process as a semi-automated development cycle, effectively a checkout, make changes, commit cycle. Only instead of manually inserting your changes you have compare tools to assist you along. After all you've already made all the code changes in your branch!

To Merge:

  1. Team -> Merge
  2. Branch or Version to be Merged (end tag): This is the name of your development branch tag
  3. Common Base Version: This is the name of your root tag for the branch (remember step 1 from the earlier section?). This should have been auto populated by the tool, but if not, add it yourself
  4. I like to Preview the merge in synchronize view so I can ensure that nothing is getting in that shouldn't be. Depending on your bravery, this is the option I would suggest. Click the Finish button
  5. The Synchronize Perspective will come up and any differences found between your destination branch and your source branch will be shown in an expandable list in the left
  6. For any file you can open it in a comparison tool to see what it was before and merge changes individually (remember to save the file when done!) or you can right click on the file and select merge from the expandable list. If you manually merge with the comparison tool, you can select "Mark as Merged" in the expandable list to remove the file from your todo list.
  7. Once you've decided what to do with the file it will be removed from the list. The goal is to action each file
  8. Now that all your changes have been merged, switch back to the Java perspective and select Team -> Synchronize with Repository , the Synchronize Perspective will come back up.
  9. This time select Commit to push all your changes into the repository.
  10. Fin!

Hope that helped. Provided below for reference is the contents of the help document that guided me to victory!

Eclipse SDK Help - Merging a Branch

Ensure that the destination is loaded into your workspace. This is the most important part and the part I missed when trying to do it a couple of times.

For example, if you wish to merge your changes into HEAD, make sure the project is shared with HEAD in your workspace(not the branch you have been working on). To do this, select the project and choose Team > Replace With > Another Branch or Version from the context menu. Then select the branch to replace with.

From this point, choose Team > Merge and then select the branch you want to merge into HEAD.

I agree this is working other way around, if changes in YOUR_BRANCH needs to be updated to HEAD,

1) commit changes to YOUR_BRANCH 2) swap local branch to HEAD 3) merge HEAD witch changes made in YOUR_BRANCH

therefore you need to be in HEAD and "take" changes from YOUR_BRANCH (instead of sending changes from YOUR_BRANCH to HEAD).

I just had to do this. While the answers above were similar, I found they weren't specific to what I needed to do.

  • As already stated, ensure your detination branch (usually head) is already checked out.
  • Then, highlight the files you know have changed in your branch (or the whole project, whatever), and select Team -> Merge . In the dialog box that pops up, choose for " Branch or version to be merged (end tag) ", the source branch you want to take your files from.
  • In my case this auto populated the " Common base version (start tag) ", but if it isn't, then this will be the tag that was created when the branch was created.

When you preview the changes they will appear in the normal CVS synchronise view. When you merge the files, they will be brought into your local workspace (which from earlier is your destination branch) as changes. At this point you will need to check them into CVS.

Frankly, there is no easy, clean way unless you have been anticipating and planning for this merge right from the time you branched.

However, I found a hack that works perfectly, which I've described in a blog post .

I struggled with this also and the above answer was not helpful until I checked the "Perform the merge into local workspace" radio button.

Unfortunately, I was not able to preview my merge before the two files were merged.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM