Switch happens
Lately (I mean late to the party, since both news date 5 years back), I discovered a couple of updates about Git:
- The community is shifting
from
master
tomain
as the default branch name - Modern alternatives
to the evergreen
checkout
command have been introduced
While the first is painless to adopt, the second one can be harder to accept.
You've probably typed git checkout
hundreds (thousands?) of times.
Now someone suggests that switch
is the command for changing branches,
and restore
is the go-to for retrieving files from depths.
To be fair, there aren't many pros to embracing these changes.
Perhaps, if you are a novice, it might be easier to learn these separate commands rather than all the nuances of checkout
.
But, if you're already proficient with checkout
, just stick with it.
That said, Git documentation hasn't deprecated checkout
,
and I suppose it never will, given all the existing scripts and automation built on top of it.
Conversely, both switch
and restore
documentation pages still carry,
from their introduction in 2019, the reminder:
"THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE."
Despite all of this, I purposely decided to switch (pun intended)
to the modern alternatives because I found code-related habits too comfortable.
Learning new ways to do the same thing keeps your mind flexible, and rebases (damn) your curiosity.
Maybe after some time, you'll find this method cleaner.
Maybe you won't, and you'll revert (that's enough) to checkout
.
Automation is for machines.
We're humans. We evolve. One commit at a time.