3 ms·
> Why do you create a branch via the "git checkout" command? git checkout -b foo is just a shortcut for git branch foo git checkout foo > Why do you d
by jolmg 4y ago
> Why do you create a branch via the "git checkout" command?
git checkout -b foo
is just a shortcut for
git branch foo
git checkout foo
> Why do you delete tags using "git tag -d" but delete stashes using "git stash drop"?
That is inconsistent. One has an interface of `git <thing> <options-to-manage-thing>` and the other `git <thing> <subcommand-actions-for-thing>`. I imagine what happened is the former was the original and was probably thought to be sufficient, but then it wasn't for `stash` and the latter was introduced for more flexibility. The inconsistency is probably from backwards compatibility.
It might be worth noting that, at least as far as I know, git was like the first to use or at least popularize subcommands. It'd be understandable if they didn't include support for sub-sub-commands from the get-go.
> If you want to blow away local uncommitted changes, you can use "git reset", "git reset --hard" or "git checkout (file)" - which (I think) all do totally different things.
git-reset is mainly about resetting the branch, index, and/or working tree to a given ref. git-checkout is mainly about checking out a ref, setting HEAD and syncing the working tree to it. They're different things with an overlap. I would say that's not really inconsistent. It would only appear so when one only learns specific patterns of commands for subsets of their function, like "blow away local uncommitted changes", which in this case fits in their overlap.
- josephg 4y agoThat can all be true, but it doesn't make git any less of a nightmare to learn. Even very experienced git users make mistakes and need to google things all the time. Its become almost a trope at multiple places I've worked that even once in awhile someone makes a mess of their git repository, and needs to call for help from one of the 2 people in the entire office who understand git enough to unbreak it. Another annoying inconsistency: git tag prints a list of tags. Git branch prints a list of branches. Git commit prints ... modified files? And git stash modifies the stash. You need git stash list to see the stash. What!? I get it; its a complex tool. Its managing 4 different storage areas for your code (the repository, the staging area, the index and the stash). It also manages tags, branches, remotes and configuration. And it has multiple networking interfaces. But I can't escape the conclusion that its just not a very good user interface. A good interface wouldn't be so hard to use. Redis is more complex, but I don't make so many mistakes using the redis cli. Awk is more powerful - but its much more intuitive. And cargo probably has more subcommands than git does, but I don't get lost in them. Git? Git is a mess.
- kevin_thibedeau 4y ago> It might be worth noting that, at least as far as I know, git was like the first to use or at least popularize subcommands. In this domain it was popularized by CVS which merged the separate programs used for RCS.
- jolmg 4y agoYes, I was mistaken. Even subcommands like `checkout` didn't originate with git. https://www.gnu.org/software/trans-coord/manual/cvs/html_node/checkout-examples.html#checkout-examples https://www.gnu.org/software/trans-coord/manual/cvs/html_nod...