This is definitely one of those “because I always forget how to do it” posts.
I’ve got a large, multi-branch repository with a decade plus of commits. It’s much quicker to checkout just the branch I want, and with only the most recent commits (aka shallow clone):
# shallow clone just the wat branch: git clone --depth 1 --single-branch --branch wat email@example.com:jaygooby/example.git
But then later, and because I’ve forgotten I’ve done the single-branch shallow clone, I can’t checkout other branches:
git checkout --track feature/weevils fatal: 'feature/weevils' is not a commit and a branch 'weevils' cannot be created from it
Arg! So you need to:
git remote set-branches --add origin feature/weevils git fetch origin git checkout feature/weevils
And then you’re good to go.
- Patch for aarch64 (aka arm64) openssl 1.0.2 'relocation R_AARCH64_PREL64 against symbol OPENSSL_armcap_P error'
- TIL: the `NO_COLOR` informal standard to suppress ANSI colour escape codes
- Copy the contents of a branch into an existing git branch without merging
- Adding search to a static Jekyll site using pagefind
- asdf, python and automatically enabling virtual envs