And don't even get me started on the nightmare that is submodules.
The whole thing reminds me of the bad old unix days of "if it was hard to write, it should be hard to understand."
And don't even get me started on the nightmare that is submodules.
The whole thing reminds me of the bad old unix days of "if it was hard to write, it should be hard to understand."
git checkout -b new-branch
... is a shortcut for: git branch new-branch
git checkout new-branch
You can create the branch or otherwise manipulate it without actually checking it out, so it's useful to have it separate and have a shortcut.(I agree that git's interface is terrible, but I disagree that this is one of those cases. :) )
I do think this is precisely one of those cases.
"Branch" is a major, repo-modifying operation; "checkout" is a trivial context switch operation. The user interface disaster here was that the major operation is treated as subservient to the trivial operation. It should be the other way around.
Therefore, the shortcut for creating a branch and switching to it should be
git branch -c new-branch
whereby the -c switch checks you into that branch immediately.Creating a branch is non-destructive and cheap, tidying up after accidental creation is also easy.
A common mistake people make when bitching about Git, is assuming that their workflow is the only workflow. Git supports a multitude of different workflows, and that fact is both a strength and a weakness.