* Proper way to checkout a tag?
@ 2010-12-01 19:38 Dun Peal
2010-12-01 19:51 ` Jonathan Nieder
0 siblings, 1 reply; 4+ messages in thread
From: Dun Peal @ 2010-12-01 19:38 UTC (permalink / raw)
To: Git ML
Hi. We tag our releases with names like "release-0", "release-1" and
so forth. Tags (lightweight ones) seem like the perfect markers for
these releases since we want a reference that can't ever change (as
opposed to a head).
The problem is that since there's no head pointing to each release, if
our users just:
$ git checkout release-1
When they want to build that release, they get into a detached HEAD
state. I've always construed detached HEAD as a non-standard state,
and it doesn't seem proper to reach it regularly in the course of a
standard operation like checking out past releases.
It's particularly confusing for our users who are new to Git.
Any thoughts, or alternative methods to do this?
Thanks, D
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Proper way to checkout a tag?
2010-12-01 19:38 Proper way to checkout a tag? Dun Peal
@ 2010-12-01 19:51 ` Jonathan Nieder
2010-12-01 20:16 ` Dun Peal
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Nieder @ 2010-12-01 19:51 UTC (permalink / raw)
To: Dun Peal; +Cc: Git ML
Hi,
Dun Peal wrote:
> The problem is that since there's no head pointing to each release, if
> our users just:
>
> $ git checkout release-1
>
> When they want to build that release, they get into a detached HEAD
> state. I've always construed detached HEAD as a non-standard state,
> and it doesn't seem proper to reach it regularly in the course of a
> standard operation like checking out past releases.
>
> It's particularly confusing for our users who are new to Git.
Any ideas for making the detached state more friendly?
The idea is this: when you check out a tag or a remote-tracking
branch, it is not to make changes to it. Tags are unchanging,
remote-tracking branches track remote state that the user does not
directly control. So what does it mean to check out such a thing?
There are two possibilities:
If you are checking out that commit to examine it, test it, maybe
write a few one-off patches, then any work built from there does not
need to be remembered (except in the HEAD reflog, to avoid expensive
accidents). You can make an experiment permanent with
git checkout -b newbranch
If you are starting a new line of development, it needs to get a name.
Long ago this was the only use case supported. Even today it is often
a good way to go:
git checkout -b newbranch release-1
Hope that helps.
Jonathan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Proper way to checkout a tag?
2010-12-01 19:51 ` Jonathan Nieder
@ 2010-12-01 20:16 ` Dun Peal
2010-12-02 8:33 ` Michael J Gruber
0 siblings, 1 reply; 4+ messages in thread
From: Dun Peal @ 2010-12-01 20:16 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Git ML
On Wed, Dec 1, 2010 at 1:51 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> The idea is this: when you check out a tag or a remote-tracking
> branch, it is not to make changes to it. Tags are unchanging,
> remote-tracking branches track remote state that the user does not
> directly control.
Yes, users checkout a release tag just so they can build parts of it.
There's definitely no intention of creating new changes on top of
them, and if there is then it should properly be a head (branch).
I guess that's exactly the use-case for detached HEAD, so I guess the
answer is that we should all stop being afraid of that superficially
scary term.
Thanks, D
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Proper way to checkout a tag?
2010-12-01 20:16 ` Dun Peal
@ 2010-12-02 8:33 ` Michael J Gruber
0 siblings, 0 replies; 4+ messages in thread
From: Michael J Gruber @ 2010-12-02 8:33 UTC (permalink / raw)
To: Dun Peal; +Cc: Jonathan Nieder, Git ML
Dun Peal venit, vidit, dixit 01.12.2010 21:16:
> On Wed, Dec 1, 2010 at 1:51 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> The idea is this: when you check out a tag or a remote-tracking
>> branch, it is not to make changes to it. Tags are unchanging,
>> remote-tracking branches track remote state that the user does not
>> directly control.
>
> Yes, users checkout a release tag just so they can build parts of it.
> There's definitely no intention of creating new changes on top of
> them, and if there is then it should properly be a head (branch).
>
> I guess that's exactly the use-case for detached HEAD, so I guess the
> answer is that we should all stop being afraid of that superficially
> scary term.
It's really one of the most useful features of git (as Jonathan
explained). There are two things which make it scary:
- The name. We could call it differently (free head, unbound head,
branchless head, west coast head...).
- The garbage collection. It's easy to commit on top of a detached head
by mistake, and once you switch away from that, it's difficult to find
it again (reflog) and easy to lose (gc/prune).
Though the "throw-away" nature of detached heads is a useful feature, we
could possibly help users who commit on top of them better.
Michael
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-02 8:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-01 19:38 Proper way to checkout a tag? Dun Peal
2010-12-01 19:51 ` Jonathan Nieder
2010-12-01 20:16 ` Dun Peal
2010-12-02 8:33 ` Michael J Gruber
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).