If I'm on the commandline, and I'm in the master branch, and I want to create a new branch and immediately start working on it, I'd just do git checkout -b foo
.
So I'm looking for the magit equivalent to this, i.e., I'd like to be able to call some magit function from within a branch, and then find myself working on the same buffer, but in a new branch that I've named. Once I find that function, I intend to bind it to a key so that I can avoid having to muck around with transient states and such.
In the magit docs, I see two different commands that might qualify:
magit-branch-and-checkout
which, according to the manual, "creates a new branch likemagit-branch
, but then also checks it out." (Incidentally, this is kind of a bizarre bit of documentation, since according to the very same page of the manual,magit-branch
does not, in fact, create a new branch, but rather is a prefix command that puts one in a branching transient stage. so... huh??)magit-branch-checkout
which, according to the docs, takes the name of a branch from the user (I assumemagit-branch-and-checkout
must do that too, right? unless, like, magit just picks a name for you for the new branch?), and then, per the docs, "If the user enters a new branch name, then it creates and checks that out, after also reading the starting-point from the user."
So, those sound like the exact same functionality. Except maybe that magit-branch-checkout
asks for a "starting point" (is that a commit hash? a preexisting branch? we are not told.). But if that's the difference between the two, then this raises a sub-puzzle, viz.: how does magit determine the starting point for whatever magit-branch-and-checkout
does?
So if I wanted to just do the magit equivalent of git checkout -b foo
and immediately be working on the buffer in the new branch, would I use one of those? Something else entirely? Impossible within magit?
(I really wish there were a translation table somewhere from ordinary commandline git calls to magit function calls.)