Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

git switch --detach


But "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.


That'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).


or the shorter `git switch -d`


Not to be confused with `git switch -D`, a shorthand for `git switch --delete`


Are you being sarcastic? I can’t find the --delete option in git-switch man page.


I am. The fact that you had to look is the point.


I 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/ though this one is not actually hard).


I 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.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: