From: Michael J Gruber <git@drmicha.warpmail.net>
To: Howard Miller <howardsmiller@googlemail.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Commit to wrong branch. How to fix?
Date: Fri, 04 Sep 2009 18:19:00 +0200 [thread overview]
Message-ID: <4AA13DF4.4050604@drmicha.warpmail.net> (raw)
In-Reply-To: <88A0A7C2-7DCB-45A3-B196-BED2A8AC9405@googlemail.com>
Howard Miller venit, vidit, dixit 04.09.2009 17:54:
> I commited to the wrong branch and I can't figure out what to do. To
> make matters worse I then did 'git reset HEAD^' which has made things
> much worse. It didn't remove the commit and now I can't change
> branches. I'm utterly confused. Any help much appreciated!
>
> Moral - use git status liberally and read it carefully before doing
> anything. A 'git undo" command would be great is someone is feeling
> generous :-)
Whatever happens, don't panic ;)
Let's say "geesh" is the branch on which you committed by mistake, and
which you have reset.
git reflog geesh
which show you what has happened to that branch lately. In particular,
it will list the "lost" commit. (Most probably it is the same as geesh@{1}.)
git tag sigh sha1ofthatcommit
will assign the tag "sigh", so that it won't get lost by doing "git gc"
or such. Now you can lean back!
Next step is committing "sigh" to the right branch. Depends on how you
arrived at that commit. Did you commit the complete tree you wanted, or
did you apply a change to geesh which you rather had wanted applied to
some other branch?
Michael
next prev parent reply other threads:[~2009-09-04 16:19 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 [this message]
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
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=4AA13DF4.4050604@drmicha.warpmail.net \
--to=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 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).