Using Branches with CVS

Creating a new branch

Use the following commands to create a CVS branch w/o a working tree. The following commands create a branch from the HEAD.

export DEVROOT=/home/ksedgwic/devel
export PROJECT=myproj
export BRANCH=mumble

# Create a static tag.
cvs rtag ${BRANCH}_branch_pt ${PROJECT}

# Create a branch tag at the static tag.
cvs rtag -b -r ${BRANCH}_branch_pt ${BRANCH}_branch ${PROJECT}

# Make a new working directory.
mkdir -p ${DEVROOT}/${BRANCH}

# Check out a copy of the new trees.
cd ${DEVROOT}/${BRANCH}
cvs co -r ${BRANCH}_branch ${PROJECT}

Merging changes from the HEAD onto your branch

Use the following commands to merge changes from the HEAD onto your branch.

export DEVROOT=/home/ksedgwic/devel
export PROJECT=myproj
export BRANCH=mumble

# Create a static tag on the HEAD (note the number '1').
cvs rtag  ${BRANCH}_branch_pt1 ${PROJECT}

# Merge in changes between the previous and current static tags.
cd ${DEVROOT}/${BRANCH}/${PROJECT}
cvs update -d -j ${BRANCH}_branch_pt -j ${BRANCH}_branch_pt1

If you ever need to merge from the HEAD onto your branch again, you would create a static tag named ${BRANCH}_branch_pt2 and pull the differences between ${BRANCH}_branch_pt1 and ${BRANCH}_branch_pt2.

Merging changes from your branch back to the HEAD

export DEVROOT=/home/ksedgwic/devel
export PROJECT=myproj
export BRANCH=mumble

# Mark the branch with a merge point first.
cvs rtag -r ${BRANCH}_branch ${BRANCH}_merge_pt ${PROJECT}

# Revert your tree to the HEAD.
cd ${DEVROOT}/${BRANCH}/${PROJECT}
cvs up -PdA

# Merge the changes.
cvs update -d -j ${BRANCH}_branch_pt -j ${BRANCH}_merge_pt

If you ever need to merge changes from your branch onto the HEAD again you can create ${BRANCH}_merge_pt1 and merge the differences between ${BRANCH}_merge_pt and ${BRANCH}_merge_pt1.