- 1 directory has 2 files:
test1.c
,test2.c
- 2 directory has 0 files
How can I copy only test1.c
to second directory, using "merge".
test1.c
, test2.c
How can I copy only test1.c
to second directory, using "merge".
First, the directory need to be the same, in two different branches (or you wouldn't talk of merging in this case, simply duplicating files)
Second, if you merge that directory between two version of said directory between two branches, you will end up with test1.c
and test2.c
... empty.
That is because merging a folder isn't enough: that only update the list of files, not the content of files within that folder.
The easiest way to recursively merge (the folder and everything inside) is to use the command cleartool findmerge
(for ClearCase 7.x, before ClearTeam 8.x).
See "Clearcase: findmerge
usage".
A merge is always performed in the destination view, so go to a view which select the folder in the right destination branch (and where that folder is for now still empty):
cd /path/to/view/avob/yourFolder
cleartool findmerge . -nc -fver .../sourceBranch/LATEST -merge
Note: if you are using ClearCase UCM, you will have to set an activity first, before launching the merge.
Before completing the merge (ie before checking in everything), you will be able to remove (cleartool rmname test2.c
) the file you don't want.
here is a quick&dirty solution to merge 2 directorys in linux (bash)
merge.sh:
#!/bin/bash
# params
source="$1"
target="$2"
# prog
IFS="
"
if [[ ! -d $source ]]; then
echo "sourcedir not exists!"
exit 1
fi
[[ ! -d $target ]] && mkdir -p $target
cutlength=${#source}
for o in `find $source -type d`; do
dir="${o:$cutlength}"
newdir="$target$dir"
[[ ! -d "$newdir" ]] && mkdir -p ${newdir}
done
for o in `find $source -type f`; do
file="${o:$cutlength}"
newfile="$target$file"
[[ ! -f "$newfile" ]] && cp ${o} ${newfile}
done
I just wrote it to merge 2 directorys together, and it works fine for it. Its really dirty and hast almost none security code. So be carefull by copy&paste