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

Re: How to fix “Your branch and 'origin/master' have diverged” after editing a commit that came before a pull?

From
Jeff King <peff@peff.net>
Date
Nov 21, 2010, 16:30 UTC
Message-ID
<20101121163001.GA29216@sigill.intra.peff.net>
In-Reply-To
<AANLkTikCnX5aBrmh9+wnb9JyOiynv0zhrpdMJwbhL2ji@mail.gmail.com>
On Sun, Nov 21, 2010 at 10:45:13PM +0800, Gavin Guo wrote:
Show 8 quoted lines
> > To fix it, what you want to do is recreate the history on top of B' as
> > it happened on top of B. So first you go back to C', the last commit
> > just before the commits from upstream that were rewritten. (you will
> > have pick its sha1 out of the log):
> >
> >  git checkout -b temp B'
> 
> I think you mean git checkout -b temp C'
Yes, sorry. You should base your temp branch on C'.
Show 9 quoted lines
> >  git rebase --onto temp F'^ branch_name
> [...]
> > At that point your original branch should be in the state you want. You
> > can delete the temp branch with "git branch -D temp".
> 
> I'm sorry that I can't understand "your original branch should be in
> the state you want" ?
> You only create a temp branch, and rebase some commits on it, right ??
> What does that related to original branch ??

The three-argument form of rebase above will switch to branch_name (your original branch), consider F'^ as the upstream, and rebase F'^..branch_name on top of the commits in "temp".

-Peff
Previous: Gavin GuoNext: Yang Zhang
Message 6 of 8 in “How to fix “Your branch and 'origin/master' have diverged” after editing a commit that came before a pull?”
  1. Yang ZhangNov 20, 2010
  2. Yang ZhangNov 20, 2010
  3. Jeff KingNov 20, 2010
  4. Yang ZhangNov 20, 2010
  5. Gavin GuoNov 21, 2010
  6. Jeff KingNov 21, 2010
  7. Yang ZhangNov 21, 2010
  8. Jeff KingNov 22, 2010

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.