[Libreoffice] Git detached HEAD (no branch) was: newish to git: howto recover from bad merge?
Kohei Yoshida
kyoshida at novell.com
Fri Nov 19 08:31:49 PST 2010
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 at novell.com>
More information about the LibreOffice
mailing list