dingus

/ˈdɪŋəs/ Something whose name is unknown or forgotten

Cheap context switching with git-worktree

April 2022

Git supports multiple checkouts from a single repository, allowing for multiple working directories linked to a single repository.

For arguments sake let’s say you’re working in a feature branch and spot a typo. Damn! Instead of committing work-in-progress to switch branches git-worktree can checkout another branch to a temporary working directory.

$ git worktree add ../copy-changes main
$ cd ../copy-changes

Once complete you return to you’re main working directory and clean-up.

$ cd ../web-app
$ git worktree remove ../copy-changes

🧙🏻‍♂️