git: create a throwaway branch
• 117 words • 1 min • updated
⚠️ This post is over one year old. It may no longer be up to date or relevant. Opinions may have changed.
Let’s say you want to submit a quick, perhaps even trivial, one-off pull request (PR).
One step you can do to minimize the number of decisions1 to make is to have a git alias that creates a branch with an arbitrary name.
~/.gitconfig
ini
# ...
[alias]
nbt = !git nb \"thiagowfx/$(shuf -n1 /usr/share/dict/words | tr \"[:upper:]\" \"[:lower:]\")\"Running git nbt2 will create a branch such as thiagowfx/foo.
The {username}/ prefix is to make it easier to attribute your branches to
yourself, which can be handy when working collaboratively with other engineers
in a team.
The word after the slash is sourced from dictionary words on your system.
-
See https://en.wikipedia.org/wiki/Decision_fatigue, https://en.wikipedia.org/wiki/The_Paradox_of_Choice. ↩︎
-
nbtstands for “new branch throwaway”. ↩︎