4 ms·
Wholeheartedly agree with this suggestion. I don't think I have used the incomprehensible `checkout` command once since I learned that `switch` and `restore` e
by marssaxman 2y ago
Wholeheartedly agree with this suggestion.
I don't think I have used the incomprehensible `checkout` command once since I learned that `switch` and `restore` exist, and the previous years-long state of perpetual low-grade irritation I had felt toward git has diminished accordingly.
- kazinator 2y agoWhat do you use for navigating in the branch history when doing a git bisect? Can you use switch for that?
- marssaxman 2y agoI'm afraid I have no idea - I've never needed to use `git bisect`.
- afdbcreid 2y agogit switch --detach
- frizlab 2y agoor the shorter `git switch -d`
- lostmsu 2y agoNot to be confused with `git switch -D`, a shorthand for `git switch --delete`
- frizlab 2y agoAre you being sarcastic? I can’t find the --delete option in git-switch man page.
- lostmsu 2y agoI am. The fact that you had to look is the point.
- frizlab 2y agoI don’t see the point though. That it’s impossible to know all of git’s options by heart? I mean that’s obvious and true of most software (https://xkcd.com/1168/ https://xkcd.com/1168/ though this one is not actually hard).
- kazinator 2y agoI do see a point though. Ostensibly, sure, it's hard to be so confident that a program does not have a certain feature that you can deny it without looking. But think about this case. Would it make sense for git switch to have a delete option? Of course not. But you can't be sure, because, git. The feeling is that they would merge something like that.
- deleted 2y ago[deleted]
- kazinator 2y agoBut "git switch --detach master" leaves you detached. So switch is just a dumber checkout that has to be told when to detach or not instead of inferring it from the kind of revision.
- remram 2y agoThat's usually a good thing, setting your HEAD to a symbolic ref or a commit are very different operations. Having a switch makes sense and probably catches beginner errors rather than letting them know afterwards. I don't feel like typing 'git s -d <branch>' has slowed me down in practice but you're technically right of course (or I would add a 'd="switch -d'"' alias).
- remram 2y agoI think you're asking for 'git switch -d' (for detached). In practice you will still need 'git reset' but only with a branch parameter (all 'git reset -- paths' can be replaced with 'git restore'), usually with --keep, --soft, or --mixed.