From: Jakub Narebski <jnareb@gmail.com>
To: tactical <a5158017@nepwk.com>
Cc: git@vger.kernel.org
Subject: Re: More Beginning Git Questions
Date: Mon, 26 Sep 2011 11:03:59 -0700 (PDT) [thread overview]
Message-ID: <m37h4vp4f0.fsf@localhost.localdomain> (raw)
In-Reply-To: <1aec7c1qq0n56.sxybjnsj6ngr$.dlg@40tude.net>
tactical <a5158017@nepwk.com> writes:
> Konstantin Khomoutov wrote:
>
>>>>> From what I read, detached heads are subject to garbage collection.
>>>>
>>>> No, HEAD is protected against garbage collecting. To be sure you
>>>> should name a branch when switching branches, though reflog would
>>>> protect you for 30 days (by default) even if you don't do that.
>>>
>>> So Git doesn't really support anonymous branching as part of a normal
>>> workflow.
>>
>> I perceive a certain logical fallacy here: you cannot switch between
>> anything anonymous because to switch, you should somehow identify
>> something to switch to--a name in whatever sense we put into this word.
>
> In Mercurial, you can just update to a particular changeset (and you
> identify that changeset by repository-local revision number or globally
> unique ID) and then commit again. The point is that there's no need to
> give a label to a head in Mercurial (although you can if you want to, using
> Mercurial bookmarks, which are basically the same as what Git uses).
>
> Here's an example of anonymous branching:
>
> c:\test>hg init
>
> c:\test>echo test>foo
>
> c:\test>hg commit --addremove -m initial
> adding foo
>
> c:\test>echo first>>foo
>
> c:\test>hg commit -m first
>
> c:\test>hg log
> changeset: 1:3e895ec28d6c
> tag: tip
> user: tactical
> date: Mon Sep 26 01:39:46 2011 +0100
> summary: first
>
> changeset: 0:b51644bb3450
> user: tactical
> date: Mon Sep 26 01:39:40 2011 +0100
> summary: initial
>
> c:\test>hg update 0
> 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>
> c:\test>echo second>>foo
>
> c:\test>hg commit -m second
> created new head
>
> c:\test>hg glog
> @ changeset: 2:35c82a7e7de1
> | tag: tip
> | parent: 0:b51644bb3450
> | user: tactical
> | date: Mon Sep 26 01:40:10 2011 +0100
> | summary: second
> |
> | o changeset: 1:3e895ec28d6c
> |/ user: tactical
> | date: Mon Sep 26 01:39:46 2011 +0100
> | summary: first
> |
> o changeset: 0:b51644bb3450
> user: tactical
> date: Mon Sep 26 01:39:40 2011 +0100
> summary: initial
>
> I now have two anonymous branches, and these will never be garbage
> collected. I can easily update to either branch with "hg update 1" or "hg
> update 2" (or "hg update 0" again, if i want to create yet another
> anonymous branch).
In my opinion the need to examine either log ('hg glog') or heads
('hg heads'?) to see how to switch to anonymous branch is a PITA
that far outweights the need to name branches (to give a temporary,
local-only branch name) in Git.
Nb. by using "detached HEAD" for anonymous branch I meant the
following:
$ git checkout --detach
$ ...
$ <work on detached head>
worth saving?
Y. $ git branch -b t foo/temp
$ git checkout <other branch>
N. $ git checkout <other branch>
> > The branch names is just a way to not mess with
> > SHA-1 names of commits (and to have references to those commits to keep
> > them out of consideration for garbage collection).
> > Hence the idea to demand support for anonymous branches in Git's model
> > is just unfounded.
>
> I think it's simply a weakness of Git. There are zero problems with
> anonymous branching in Mercurial, and it's a very powerful and simple
> system.
IMVVVHO it is just remains of bad initial design decision of Mercurial
about representing branches ;-PPPPPPP
Only now Mercurial has something (transferable bookmarks) which
approaches flexibility and usability of Git branches. It took them
how long... and even then there is a [supposedly] user-friendly but
flexibility-reducing notion that branch (bookmark) names are global.
Not that Git didn't and doesn't have its share of bad design decisions
(like autimatically committing a merge).
--
Jakub Narębski
next prev parent reply other threads:[~2011-09-26 18:04 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-23 14:41 More Beginning Git Questions Jon Forrest
2011-09-23 16:11 ` Matthieu Moy
2011-09-23 17:42 ` Jakub Narebski
2011-09-23 18:14 ` Jon Forrest
2011-09-23 18:44 ` Mihamina Rakotomandimby
2011-09-23 18:59 ` Jakub Narebski
2011-09-24 20:22 ` tactical
2011-09-24 20:53 ` Frans Klaver
2011-09-24 22:17 ` tactical
2011-09-24 22:59 ` Seth Robertson
2011-09-25 2:16 ` tactical
2011-09-25 13:22 ` Jakub Narebski
2011-09-25 20:23 ` tactical
2011-09-25 20:58 ` Jakub Narebski
2011-09-25 21:07 ` tactical
2011-09-26 0:34 ` Konstantin Khomoutov
2011-09-26 0:56 ` tactical
2011-09-26 1:34 ` Andrew Ardill
2011-09-26 1:42 ` tactical
2011-09-26 18:03 ` Jakub Narebski [this message]
2011-09-24 21:10 ` Jakub Narebski
2011-09-24 22:10 ` tactical
2011-09-25 13:24 ` Jakub Narebski
2011-09-23 18:47 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m37h4vp4f0.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=a5158017@nepwk.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).