From: Jakub Narebski <jnareb@gmail.com>
To: Howard Miller <howardsmiller@googlemail.com>
Cc: Michael J Gruber <git@drmicha.warpmail.net>,
"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Commit to wrong branch. How to fix?
Date: Fri, 04 Sep 2009 11:51:48 -0700 (PDT) [thread overview]
Message-ID: <m33a72lf0h.fsf@localhost.localdomain> (raw)
In-Reply-To: <26ae428a0909041103p4ecba8efvff6223f902e14f1a@mail.gmail.com>
Howard Miller <howardsmiller@googlemail.com> writes:
> I must admit I don't understand what 'reflog' is (more reading) - not heard
> of that before.
I'll try to explain it with some ASCII-art.
Let's say that you had the following situation:
...---A---B---C <-- foo <--- HEAD
Current branch is named 'foo', and three last commits on it are named
A, B, C.
Now you create new commit (I assume that you comitted unwanted
changes; the recipe would be different (much simpler) if you have
realized that you are on wrong branch[1] before committing)
[1] git aware shell prompt, countaing branch name, could help there
...---A---B---C---X <-- foo <--- HEAD
Reflog records that commit in 'foo' reflog and in HEAD reflog
foo@{0}: X
You have realized that you are on wrong branch, and you did
"git reset --hard HEAD^" (too early)
...---A---B---C <-- foo <--- HEAD
\
\-X
Reflog records that fact (it records where tip of branch was)
foo@{0}: C
foo@{1}: X
Then if you want to create new branch 'bar' with X, you would do
$ git checkout -b bar foo@{1}
If you wanted to have this commit on some other existing branch, let's
call it 'baz', you would do instead (I think):
$ git checkout baz
$ git cherry-pick foo@{1}
HTH (hope that helps).
--
Jakub Narebski
Poland
ShadeHawk on #git
prev parent reply other threads:[~2009-09-04 18:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-04 15:54 Commit to wrong branch. How to fix? Howard Miller
2009-09-04 16:19 ` Michael J Gruber
2009-09-04 17:11 ` Erik Faye-Lund
2009-09-05 12:51 ` Michael J Gruber
2009-09-04 18:01 ` Howard Miller
2009-09-04 18:03 ` Howard Miller
2009-09-04 18:51 ` Jakub Narebski [this message]
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=m33a72lf0h.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=howardsmiller@googlemail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.