Working with multiple branches

26th March 2023


Git provides a way to experiment with different changes or test multiple versions of the code by switching among branches. However, this can become cumbersome and time-consuming. This is where git-worktree comes in handy, allowing developers to have multiple branches checked out at the same time and experiment with their code freely.

Introduced in version 2.5, According to https://github.blog/2015-07-29-git-2-5-including-multiple-worktrees-and-triangular-workflows. git-worktree enables developers to check out multiple commits simultaneously without making a full copy of the repository for each of them. This is especially useful when the repository is massive or when an arduous compilation is needed for testing purposes.

Usecase

My daily driver is Void Linux. To contribute to its package repository, I organise my local directory structure as follows,

void/
|-- WIP
|   |-- pandoc
|   `-- singularity
`-- void-packages
    |-- CONTRIBUTING.md
    |-- COPYING
    |-- Manual.md
    |-- README.md
    |-- common
    |-- etc
    |-- hostdir
    |-- masterdir
    |-- srcpkgs
    `-- xbps-src

such that within the void directory, there are two main subdirectories. The void-packages is kept in sync with the upstream repository. In the WIP directory, I check out branches where I work on updating or adding new packages, such as pandoc and singularity.

(Last updated on 10/09/2023)

2 Small bug fix in the Planck Likelihood Code | All logs