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

Is there any way to "interrupt" a rebase?

From
HWHilco Wijbenga <hilco.wijbenga@gmail.com>
Date
Feb 19, 2018, 19:35 UTC
Message-ID
<CAE1pOi1XtrWqG7mOdrNt10YoZG0LOAB7i9cc1Gi8oWhULxE57A@mail.gmail.com>
Hi all,

When maintaining a long running branch, I regularly rebase onto our active development branch so that my branch stays up-to-date. What happens fairly often is that during such a rebase, Git will exit because of rebase/merge conflicts. Nothing unexpected there, of course, but as it sometimes turns out, the conflict should have been fixed in an earlier commit. The only way that I know of to fix this, is to abort the rebase and start over with "git rebase ... --interactive" then "edit" every commit and go through them one-by-one. This is often overkill, though. Is there a better way? Perhaps I could "rewind" the rebase to an earlier commit and restart from there?

So a scenario like this:

my-branch : X -> A -> B -> C -> D -> E -> F -> G base-branch : X -> Y

git rebase --onto base-branch HEAD~7 commit A --> conflicts ... lots of work ... commit B --> conflicts ... lots of work ... commit C (Git handles conflicts) commit D (no conflict) commit E --> conflicts ... er, that should have been fixed in commit C

How do I keep all the work I did for commits A and B? I get the impression that rerere does not help here because I did not finish the rebase succesfully (and that makes perfect sense, of course). Is there a way at this point in the rebase to "go back" to commit C (so without "git rebase --abort")?

(Surely, it's not as simple as doing a "git reset --hard sha-of-commit-C" is it?)

Cheers, Hilco

Next: brian m. carlson
Message 1 of 10 in “Is there any way to "interrupt" a rebase?”
  1. Hilco WijbengaFeb 19, 2018
  2. brian m. carlsonFeb 19, 2018
  3. Hilco WijbengaFeb 19, 2018
  4. Johannes SchindelinFeb 20, 2018
  5. Johannes SchindelinFeb 20, 2018
  6. Jeff KingFeb 20, 2018
  7. Jacob KellerFeb 20, 2018
  8. Phillip WoodFeb 23, 2018
  9. Jeff KingFeb 20, 2018
  10. Phillip WoodFeb 20, 2018

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.