3 ms·
The command line is really unintuitive. Like using 'checkout -b' to create a branch but 'branch -D' to delete one.
by achates 3y ago
The command line is really unintuitive. Like using 'checkout -b' to create a branch but 'branch -D' to delete one.
- adhesive_wombat 3y ago> 'checkout -b' to create a branch Well that's actually "create a branch and then checkout that new branch". And you can use "git switch -c" if you feel the "checkout" verb is confusing. The command to just create a branch is "git branch". Git branch won't touch the HEAD pointer, that's what switch does. And if "git branch -c" were the command for "create branch and switch", it would be criticised in the exact same way: creating a branch and switching to it would be a different subcommand to that used for switching existing branches. Except now the branch command can also do "switchy" things to your HEAD pointer, but only sometimes (and the fact that checkout also only sometimes changed the HEAD is why switch was introduced).
- creamyhorror 3y agoWhat would be nicer is an interactive CLI interface for git. For example: "git switch <branch>", then if the branch doesn't exist, git asks you: "Branch <branch> does not exist; create it? [y/n]" To be fair, I've long used "checkout -b" and I don't think new branches need this, but it might be helpful in special situations like rebase/merge conflicts. I appreciate this sort of interactive CLI in other tools (apt, vite, etc.), versus having to look up the manual for the right options/switches. It's a different approach that might be more annoying to some power users, but is more friendly to most other users. (This is also where GUIs are helpful, since they display most of the useful commands and options for you. Plus they can do things like see line history by commit and list your stashes for super-easy switching; GitLens/GitLess in VSCode do these.)