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

[RFD] make rebase abort to original branch, not rebased branch

From
Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Date
Mar 13, 2011, 03:58 UTC
Message-ID
<alpine.DEB.2.00.1103122253560.15442@debian>

When git rebase is aborted, it will return the HEAD to the rebased branch (which has not moved). If the current branch is "topic" and a run of "git rebase master" is aborted, "topic" is therefore checked out, which is both what I expect and what I want. When the two-argument version of git rebase is used, as in "git rebase master topic", and then aborted, "topic" will be checked out. This is not what I would expect, although I'm aware of it by now, and usually not what I want. I would expect to be returned to the branch/commit that was checked out when I started "git rebase master topic".

In most cases, this is just a small annoyance, since it's usually quick and easy to manually switch back to the original branch. However, I have run into at least two cases where it has been a bit more annoying:

 1. When on a detached HEAD and running "git rebase HEAD topic", if
    you abort the rebase, you will have to look up the old commit in
    the reflog.
 2. I once was rebasing many old branches, mostly to see which ones
    could be rebased without conflicts. The project I was working on
    was pretty big and a lot had changed since those old branches were
    created. If a "new" branch is currently checked out and "git
    rebase master old-branch" is run and causes conflicts, the old
    branch would be checked out. In my case, this would take 5-10
    seconds. Since Junio improved rebase in 0cb0664 (rebase [--onto O]
    A B: omit needless checkout, 2008-03-15), there will be no
    checkouts of any "old" commit in the successful case, so it's a
    shame that it has to happen in the unsuccessful case when the
    rebase is aborted.
Are there valid cases where the current behavior is bettter?

I suppose we can not just change the current behavior due to backward compatibility constraints. We could introduce a configuration variable, of we could perhaps change it in 1.8.0. Maybe the problem is not big enough to do either...

/Martin
Next: Junio C Hamano
Message 1 of 5 in “[RFD] make rebase abort to original branch, not rebased branch”
  1. Martin von ZweigbergkMar 13, 2011
  2. Junio C HamanoMar 13, 2011
  3. Junio C HamanoMar 13, 2011
  4. Martin von ZweigbergkMar 13, 2011
  5. Alexander MiselerMar 13, 2011

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.