News for hackers. Stuff that matters.
Re:Can we communally deprecate git checkout? by cmgriffing on Thursday January 09, 2025 @05:05PM (#42650284)
I feel like the value of changing from `git checkout -b` to `git switch -c` is not worth the cognitive overhead of making the change.
Re:Can we communally deprecate git checkout? by kedean on Thursday January 09, 2025 @05:06PM (#42650302)
Not to mention the official docs for "switch" still state "THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE."

https://git-scm.com/docs/git-switch

Re:Can we communally deprecate git checkout? by ghewgill on Thursday January 09, 2025 @05:13PM (#42650363)
Yes. This warning in the documentation (and the same warning for "git restore") is doing nothing to help the situation. I've had to put a stake in the ground on this SO answer: https://stackoverflow.com/a/215731/893
Re:Can we communally deprecate git checkout? by epistasis on Thursday January 09, 2025 @05:21PM (#42650446)
> [At the time of writing, the git restore command has been marked as "experimental" for at least four years.]

Honestly I have not bothered to even learn switch or restore because of these warnings. If they keep them in after five years, then the commands might be removed in the next version, because clearly there's no champion behind them pushing them forward.

And the few times I have tried to learn what they do, I have not seen any benefit over my current knowledge. So why learn something that may go away and is not trusted even five years and many many versions after deployment?

Re:Can we communally deprecate git checkout? by Izkata on Thursday January 09, 2025 @05:12PM (#42650361)
This goes well with my experience from svn where "svn switch" had a high-enough chance to screw up your checkout that everyone I know just had multiple checkouts instead.
Re:Can we communally deprecate git checkout? by joshka on Thursday January 09, 2025 @06:59PM (#42651106)
I made that exact thought many years ago and came to the direct opposite conclusion. It was worth the cognitive overhead to make the change and I haven't looked back. Most of the time I'm just hitting aliases (from OMZ's git plugin) https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git e.g.

    gsw  git switch
    gswc  git switch -c
    gswd  git switch $(git_develop_branch)
    gswm  git switch $(git_main_branch)
Re:Can we communally deprecate git checkout? by BizarreByte on Thursday January 09, 2025 @05:18PM (#42650414)
I felt that way about the master to main debacle, but some angry people online won anyway.
Re:Can we communally deprecate git checkout? by disgruntledphd2 on Friday January 10, 2025 @04:21AM (#42654044)
The irritating thing about that is that the software git defaults to master, while GitHub defaults to main. I had a lot of confusion a few months back about that.
Re:Can we communally deprecate git checkout? by two_cents on Friday January 10, 2025 @10:17AM (#42656326)
You can set default branch name for your repositories in settings. Much more straightforward than in GitLab in my opinion.
Re:Can we communally deprecate git checkout? by disgruntledphd2 on Monday January 13, 2025 @03:02PM (#42688258)
Yeah, I know that now but this hit me under time pressure and caused me muh confusion for a while.
Re:Can we communally deprecate git checkout? by imoreno on Thursday January 09, 2025 @06:02PM (#42650739)
Do people really type these out, instead of just making a bash alias?
Re:Can we communally deprecate git checkout? by dwaltrip on Thursday January 09, 2025 @06:35PM (#42650958)
I would wager that 90% of people using git don’t have bash aliases.
Re:Can we communally deprecate git checkout? by g-b-r on Friday January 10, 2025 @09:37AM (#42655900)
I would wager that above 90% (of those using command-line git) do, after at most a few weeks of heavy git usage

It takes no time to add some, and it's not necessary to put them online and synchronize them; it would be a no-brainer for me to add some manually, if I had to work on a new machine for more than a few minutes (and couldn't access my usual ones from it)

Re:Can we communally deprecate git checkout? by remram on Thursday January 09, 2025 @08:35PM (#42651621)
I was always using 'co' for checkout. Made the change to switch ('git s') and revert ('git r') and it has been pretty seemless. I do wish 'git reset' defaulted to --keep.
Re:Can we communally deprecate git checkout? by camtarn on Thursday January 09, 2025 @09:22PM (#42651858)
Used to have bash aliases, but nowadays I work on so many different machine, without my dotfiles present, that aliases seem kinda pointless. I'm a fast typist.
Re:Can we communally deprecate git checkout? by moregrist on Friday January 10, 2025 @06:53AM (#42654870)
Aliases have always been a double-edged sword.

They're shorter and let you be more efficient at common tasks.

They also tend to be personal and hard to share. Which can make it harder to explain what you’re doing to a coworker for pairing/debugging/training purposes. And you have to remember both the aliases and the underlying commands/options, at least enough to remember when you don’t want to use the alias.

I don’t find that I use git subcommands with a frequency that makes me want to alias them. It’s likely that different workflows lead to different optimizations.