git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Commited to wrong branch

From
Howard Miller <howard@e-learndesign.co.uk>
Date
Sep 15, 2009, 13:27 UTC
Message-ID
<26ae428a0909150627n4e5935bcxdcdf0fdd33a44aa8@mail.gmail.com>
In-Reply-To
<26ae428a0909150558i508e5878q8a1ee7cb7311fc57@mail.gmail.com>
What's to stop me.........
* The "wrong" branch just tracks a remote so I can just dump it once I
have this fixed - (delete it and recreate it?)
* after my 'reset' the files I have in my working copy (still the
wrong branch) should be the latest version ('git reset' does not
change the working copy I think?)
* So can I grab these files (they are mostly new), checkout the
correct version, and just overwrite the existing files? I'll loose
some history but not much and I don't care
Seems too easy :-)
2009/9/15 Howard Miller <howard@e-learndesign.co.uk>:
Show 97 quoted lines
> Martin,
>
> Got as far as applying the temporary patch and I now get a load of...
>
> Reversed (or previously applied) patch detected!  Assume -R? [n]
> Apply anyway? [n]
> Skipping patch.
> 1 out of 1 hunk ignored -- saving rejects to file
> theme/onepointnine/local.css.rej
> The next patch would create the file theme/onepointnine/local.css,
>
> funnily I didn't think that file had anything to do with it, but when
> I changed branched I got
>
> T       theme/onepointnine/local.css
>
> Not sure what the T means :-(
>
> H.
>
> 2009/9/15 Martin Langhoff <martin.langhoff@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
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>
Previous: Björn SteinbrinkNext: Howard Miller
Message 16 of 20 in “Commited to wrong branch”
  1. Howard MillerSep 15, 2009
  2. Martin LanghoffSep 15, 2009
  3. Howard MillerSep 15, 2009
  4. Martin LanghoffSep 15, 2009
  5. Howard MillerSep 15, 2009
  6. Martin LanghoffSep 15, 2009
  7. Howard MillerSep 15, 2009
  8. Björn SteinbrinkSep 15, 2009
  9. Howard MillerSep 15, 2009
  10. Martin LanghoffSep 15, 2009
  11. Howard MillerSep 15, 2009
  12. Björn SteinbrinkSep 15, 2009
  13. Howard MillerSep 15, 2009
  14. Martin LanghoffSep 15, 2009
  15. Björn SteinbrinkSep 15, 2009
  16. Howard MillerSep 15, 2009
  17. Howard MillerSep 15, 2009
  18. Johannes SixtSep 15, 2009
  19. Martin LanghoffSep 15, 2009
  20. Björn SteinbrinkSep 15, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.