What I've Learnt


Listen to me ramble on about things other people already know


Git Worktree

I was reading the New Year, new GIT release post from GitHub a couple days ago, and it was highlighting some new features in git 2.7.0. The one that really caught my eye was a small improvement to git worktree (introduced in 2.5.0). Being that I was completely ignorant of git worktree prior to reading that, this minor improvement was a light bulb moment for me.

Many times, I have re-cloned a remote repo to have clean local worktree to work on, so as not to interrupt a long-running development task in another branch. git worktree addresses that problem by allowing you to create multiple working trees from a single local repository. It’s faster (no remote fetching for additional working trees), smaller on disk (eliminate multiple copies of all the repo history), and easier to keep all your trees in sync, as there’s only one local repo for all the work trees. So, fetching changes in one tree allows those changes to be visible in all trees.

Check out the worktree manpage for more details on usage and caveats (not recommended to use with submodules!).