I have a file that needs to be brought into a different branch. How do I do this from the command line. Everything seems to be geared to merging, where the file already exists in both branches.
3 Answers
You have to merge the parent directory first, so that the file shows up in the directory in the destination branch. At this point the new file will have zero size. You can then merge the file itself. The easiest way to do both of these operations is via the Version Tree view - much less error-prone than doing it via the command line.

- 208,748
- 37
- 389
- 560
-
But there are a bunch of other files in the directory that I don't want. How would I address this? – Seamus Connor Nov 17 '10 at 22:04
-
Just do an interactive merge of the directory and make sure only the file you want gets merged to the target branch - check out the target directory, open up Version Tree, draw a merge arrow from the source directory to the target directory (right click on source directory, then merge to, click on target directory), and then select graphical merge from the options. – Paul R Nov 17 '10 at 22:14
-
Key is to check the parent directory out on the destination view. – Jake1164 Jun 20 '12 at 19:00
Much simpler:
- 1/ rmname the file in the destination directory
ct co -nc . ct rmname -force file.txt
- 2/ merge the directory
ct findmerge . -ftag view_tag
with 'view_tag' a view on the source directory

- 1,262,500
- 529
- 4,410
- 5,250
I no longer have access to a clearcase environment, so this is from memory, but what you want is to link in a version from another branch into the one that you are working with.
Let's assume that you have a file new_file
that have been added on the branch new_feature
(the latest version is new_file@@/main/new_feature/5
) which you want to merge/bring into the branch maintenance
.
prompt>cleartool checkout -nc .
checking out some_dir@@/main/maintenance/2
...
prompt>cleartool ln .@@/main/new_feature/LATEST/new_file/main/new_feature/5 .
...
prompt>cleartool ci -c "linked in .@@/main/new_feature/LATEST/new_file/main/new_feature/5"
prompt>
The commands above are probably not 100% correct, but should give you the idea. You want to use cleartool ln
to avoid evil twins, because that will bring in a version from the already existing element (i.e. not creating a new twin).

- 26,565
- 10
- 94
- 165