Re: [PATCH v2] checkout: implement "-" shortcut name for last branch
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Jan 15, 2009, 13:59 UTC
- Message-ID
- <200901151500.01876.trast@student.ethz.ch>
- In-Reply-To
- <alpine.DEB.1.00.0901151413250.3586@pacific.mpi-cbg.de>
Johannes Schindelin wrote:
Show 7 quoted lines
> On Thu, 15 Jan 2009, Johannes Sixt wrote: > > You must make sure that commits referenced by LAST_HEAD are not > > garbage-collected. (I don't know if this happens anyway for symrefs in .git.) > > Note: if you used reflogs for that feature, the garbage collection could > not have killed the commit. However, it is quite possible that the > branch was deleted.
Suddenly I'm not so sure about either behaviour any more.
Consider:
$ git commit -m initial
[master (root-commit)]: created 812c476: "initial"
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 foo
$ git checkout $(git rev-parse HEAD)
Note: moving to "812c476ca23e25efa7e4d7081153ba657a127d95" which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
HEAD is now at 812c476... initial
$ git branch -D master
Deleted branch master (812c476).
$ git for-each-ref
$ git reflog expire --expire=now --all
$ git prune --expire now
$ git show
fatal: bad object HEAD
$ git show 812c476
fatal: ambiguous argument '812c476': unknown revision or path not in the working tree.
Use '--' to separate paths from revisionsOops.
Some quick RTFS shows that it indeed "only" cares about refs and reflogs.
--
Thomas Rast
trast@{inf,student}.ethz.ch