![]() (But: you can add -detach to avoid the "get on a branch" case even if it would otherwise get on the branch.) This is true even if the name is the one suggested in gitrevisions for avoiding ambiguity, i.e., heads/xyz when there's another xyz. If you specify N} or -, it will look up the N-th older branch in the HEAD reflog (with - meaning Otherwise it chooses the second method, giving you the "detached HEAD". ![]() If you want the latter, you can specify a revision by any of the methods listed in gitrevisions, except for any method that results in "getting on the branch".įor whatever reason, the algorithm chosen here-it is documented in the manual page, under -is this: If you've written a name that, when adding refs/heads/ to it, names a branch, git checkout will put you "on that branch". That's easiest to write by just writing out the branch name, without the refs/heads/ part. ![]() You can still use the existing git checkout command the same way as in pre-2.23 Git, though.) Edit, Jun 2020: In Git 2.23 or later, these are in a separate command now: git switch is the branch-changer, and it requires -detach to go to a detached HEAD git restore implements the file-restorer mentioned later in this posting. On the other hand, it would obviate all the weirdness described below. (Personally, I think these should use different command names, but that's just me. "I want to look at some particular revision, and get off any branch here's a branch-identifier that is not a branch name": e.g., git checkout 6240c5c."I want to ‘get on a branch’ here's a branch name": e.g., git checkout branch. ![]() The checkout command distinguishes between two cases (well, actually "many", but let's start with just the two :-) ): ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |