Git prevents branches with the same name. But sometimes, I want to re-use a name! Here’s my workaround.

Context: I use Bitbucket to generate branch names. It will give me a branch for a feature “User logs in” named feature/user-logs-in. That name helps me convey what a branch’s intentions are.

But what happens if I open another branch for that feature? Do I have pick a new name, just because Git says so? Not really.

My solution is to append the time since epoch, with date.

$ git checkout -b feature/user-logs-in-$(date +%s)

Branches all day:

$ git checkout -b feature/user-logs-in-$(date +%s)
Switched to a new branch 'feature/user-logs-in-1763675785'
$ git checkout -b feature/user-logs-in-$(date +%s)
Switched to a new branch 'feature/user-logs-in-1763675786'

I get to preserve the meaning, and while mostly ignoring this constraint.