3 ms·
Most of the inconsistencies, like "checkout" having three different functions, were added much later, in attempts to make UX niftier locally, without thinking a
by nine_k 3y ago
Most of the inconsistencies, like "checkout" having three different functions, were added much later, in attempts to make UX niftier locally, without thinking about the product as a whole.
- arrowsmith 3y agoCheckout can move your head to different commit and it can copy files to your working tree from a non-checked-out commit. What's it's third function?
- nine_k 3y agoIt can create a branch with -b, based on a branch of your choice (not necessarily current). I constantly use this, having created an alias: [some other branch]$ git cob feature/foo123 main
- scubbo 3y agoEh, I can squint and see that as a special-case of moving your head to another ref - the `-b` merely flagging "if this branch doesn't exist, create it instead of erroring".
- JimDabell 3y agoFor what it’s worth, this is now being separated out a bit to be clearer. You can use `git switch <branch>` to switch to an existing branch, `git switch --create <branch>` to create a new branch and switch to it, and `git restore <file>` or `git restore --source <ref> file` to restore a version of a file to your working directory.