All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Langhoff <martin.langhoff@gmail.com>
To: Howard Miller <howard@e-learndesign.co.uk>
Cc: git@vger.kernel.org
Subject: Re: Commited to wrong branch
Date: Tue, 15 Sep 2009 14:46:16 +0200	[thread overview]
Message-ID: <46a038f90909150546i508d3781id1dcd8e6c64942cf@mail.gmail.com> (raw)
In-Reply-To: <26ae428a0909150510n56b1d4eg6565a6cca8c9b46c@mail.gmail.com>

On Tue, Sep 15, 2009 at 2:10 PM, Howard Miller
<howard@e-learndesign.co.uk> wrote:
> Martin,
>
> Looked at gitk - yes there is definitely one more commit still on the
> current (wrong) branch.
>
> I deleted the offending file and have now successfully switched to the
> other (correct) branch.

ok!

so you have

A - The commit you undid, and have in the temp patch. Note that this
patch file is missing the file you've rm'd.

B - A commit you haven't "undone" on the "wrong" branch X.

 and you are on branch Y

so now...

1 - git format-patch Y^..Y  # will export that patch B into a file for you.
2 - git am 0001-whatever-the-name-of-the-file.txt # patch B
    this may need conflict resolution - read the notes it prints! If
it refuses to apply the patch, do "git am --skip" to indicate you
won't use git-am no more for this, and try applying it with the patch
utility.
3 - patch -p1 < your-patch-A.patch
4 - find and readd the file you rm'd earlier -- if you don't have
another copy, we can get it from git reflog but that'll take extra
steps :-)
5 - git commit # you're committing your patch A here

Now, review with gitk to see that you have what you want to have
there. If it's all ok...

 6 - git checkout X
 7 - git reset --hard # unstich that last stray commit
   --

hope the above helps. Git pros will see that the process could be much
shorter :-) I chose this specific path because in exporting your
patches and applying them again you can see each step.

If we were to start again, and the branches are reasonably close to
eachother (not 19_STABLE vs cvshead :-) ) then you can say

 - X has 2 bad commits that belong to Y, then
 1 - gitk X & # open gitk to visualise the commits, send it to the background
 2 - git checkout Y
 3 - git cherry-pick X^ # takes the next-to-last commit from X and
tries to apply it here - conflict resolution may be needed
 4 - git cherry-pick X # same with the very last commit on X
 5 - gitk # check that is all as you want it
 6 - git checkout X
 7 - git reset --hard X^^ # "rewind 2 commits"

hth,



m
-- 
 martin.langhoff@gmail.com
 martin@laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff

  reply	other threads:[~2009-09-15 12:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-15 10:31 Commited to wrong branch Howard Miller
2009-09-15 10:55 ` Martin Langhoff
2009-09-15 11:05   ` Howard Miller
2009-09-15 11:16     ` Martin Langhoff
2009-09-15 12:10       ` Howard Miller
2009-09-15 12:46         ` Martin Langhoff [this message]
2009-09-15 12:58           ` Howard Miller
2009-09-15 13:06             ` Björn Steinbrink
2009-09-15 13:12               ` Howard Miller
2009-09-15 13:54               ` Martin Langhoff
2009-09-15 14:11                 ` Howard Miller
2009-09-15 20:39                 ` Björn Steinbrink
2009-09-15 20:52                   ` Howard Miller
2009-09-15 21:53                   ` Martin Langhoff
2009-09-15 22:30                     ` Björn Steinbrink
2009-09-15 13:27             ` Howard Miller
2009-09-15 13:45               ` Howard Miller
2009-09-15 14:08                 ` Johannes Sixt
2009-09-15 13:46               ` Martin Langhoff
2009-09-15 11:19   ` Björn Steinbrink

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=46a038f90909150546i508d3781id1dcd8e6c64942cf@mail.gmail.com \
    --to=martin.langhoff@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=howard@e-learndesign.co.uk \
    /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.