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

Re: Commited to wrong branch

From
Martin Langhoff <martin.langhoff@gmail.com>
Date
Sep 15, 2009, 13:46 UTC
Message-ID
<46a038f90909150646t25c48d7ar1cfe4052ad0bb3b6@mail.gmail.com>
In-Reply-To
<26ae428a0909150627n4e5935bcxdcdf0fdd33a44aa8@mail.gmail.com>

On Tue, Sep 15, 2009 at 3:27 PM, Howard Miller <howard@e-learndesign.co.uk> wrote:

> 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?)

Absolutely perfect plan. In fact, there's a way to "sync" your local branch to the remote one:

 git checkout X
 git reset  origin/X
(assuming that the remote branch is 'origin/X')
> * 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?)
correct (git reset --hard OTOH will discard your changes)
> * 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

Oh... well if there were other changes to the same files in the other branch you could be carrying "other" changes. git diff to make sure you're committing what you want.

> Seems too easy :-)
It is :-)
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
Previous: Johannes SixtNext: Björn Steinbrink
Message 19 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.