Next: Pulling / Pushing, Up: Branches [Contents][Index]

#### 28.1.11.1 Switching between Branches

The various version control systems differ in how branches are implemented, and these differences cannot be entirely concealed by VC.

On some decentralized version control systems, including Bazaar and Mercurial in its normal mode of operation, each branch has its own working directory tree, so switching between branches just involves switching directories. On Git, branches are normally co-located in the same directory, and switching between branches is done using the `git checkout` command, which changes the contents of the working tree to match the branch you switch to. Bazaar also supports co-located branches, in which case the `bzr switch` command will switch branches in the current directory. With Subversion, you switch to another branch using the `svn switch` command.

The VC command to switch to another branch in the current directory is `C-x v r branch-name RET` (`vc-retrieve-tag`).

On centralized version control systems, you can also switch between branches by typing `C-u C-x v v` in an up-to-date work file (see Advanced C-x v v), and entering the revision ID for a revision on another branch. On CVS, for instance, revisions on the trunk (the main line of development) normally have IDs of the form 1.1, 1.2, 1.3, …, while the first branch created from (say) revision 1.2 has revision IDs 1.2.1.1, 1.2.1.2, …, the second branch created from revision 1.2 has revision IDs 1.2.2.1, 1.2.2.2, …, and so forth. You can also specify the branch ID, which is a branch revision ID omitting its final component (e.g., 1.2.1), to switch to the latest revision on that branch.

On a locking-based system, switching to a different branch also unlocks (write-protects) the working tree.

Once you have switched to a branch, VC commands will apply to that branch until you switch away; for instance, any VC filesets that you commit will be committed to that specific branch.

Next: Pulling / Pushing, Up: Branches [Contents][Index]