Managing Multiple Working Directories

git worktree

If you only want to do some quick git operations, like merging/rebasing other branches, but don't want to make your working directory dirty and cause unnecessarily rebuild, git worktree is a good solution. It only handles one single git repo though, and doesn't come with Chromium environment setup like gclient and install-build-deps.

If you need to have multiple working directories that you can actually build, use gclient-new-workdir instead. Using git worktree and set up environment there would be slower and use more disk space.


If you are a multitasker or want to build chromium for different targets without clobbering each other, then perhaps you'll like the script located in depot_tools. The script works by creating a new working directory with symlinks pointing to the git database(s) found in your original chromium checkout. You can have as many working directories as you want without the overhead and hassle of cloning chromium multiple times. /path/to/original/chromium chromium2

If your file system supports copy-on-write, like btrfs, gclient-new-workdir is smart enough to use reflink to save copying time and disk space. Better yet, if the source repo is a btrfs subvolume, btrfs snapshot would be created, with all the artifacts retained. You can skip environment setup, and rebuilding should be incremental. This is the most space-efficient way to create a separate working directory. See for details.

Windows devs doesn't support Windows, but you can try to do the same thing (needs to be run as admin). For the curious, the script essentially uses mklink /D and other minor tricks to setup the mirrored .git repo.

Chromium OS devs uses symlinks that will not work inside the cros_sdk chroot. If using a local Chromium source for Chromium OS, be sure to use the original working directory.