Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


On Fri, 2010-11-19 at 19:53 +0900, Takeshi Abe wrote:
$ git branch
* (no branch)
  master 

So, I'd like to expand on this mysterious "detached HEAD" thingie in
git, since I just learned about this yesterday and it might help other
people understand what the heck is going on when you are "detached".

Basically, in git, the term "branches" roughly equals tips, or the last
commits of the branches.  They are sometimes referred to as "heads" (in
lowercase) though not as frequently as branches.  The term HEAD refers
to the last commit of the current branch.

Now, you are in a "detached HEAD" when you are not in the tip of a
branch.  For example, when you check out a particular commit via its
hash, or tag, your checkout is no longer the last commit of any branch,
hence you are detached.  And, when you start committing while you are in
that state, you are committing to this detached special branch called
(no branch).

To re-apply these changes from this detached branch to the tip of a
branch, you can use git rebase e.g.

git rebase master

to re-apply your changes over the top of the master branch.  In this
particular case, since your detached branch is entirely local, it's safe
to use git rebase.

Anyway, this knowledge helped me understand git a bit more.  So, I hope
this will help others too.

Kohei

-- 
Kohei Yoshida, LibreOffice hacker, Calc
<kyoshida@novell.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.