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

Re: how to reorder commits

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Jul 20, 2009, 21:27 UTC
Message-ID
<alpine.LNX.2.00.0907201717570.2147@iabervon.org>
In-Reply-To
<f46c52560907200807heed4bbfkde15cccd2ae8151d@mail.gmail.com>
On Mon, 20 Jul 2009, Rustom Mody wrote:
Show 10 quoted lines
> I have a sequence of commits. I tried to reorder the top two in this way.
> $ git rebase -i HEAD^^
> 
> flip the two pick lines and exit vi
> 
> I find my file full of conflict markers.
> So what is the way of doing:
> HEAD becomes current HEAD^
> HEAD^ becomes current HEAD
> without having to handle conflicts ??

Note that what you're asking for here would add both changes in HEAD^ and *remove* some changes in HEAD (to get to the state where only the change that was made first has been made).

What you tried with rebase is correct, but if your changes in those commits intersect, impossible to do automatically:

Original:
 This is an example.
Change 1:

-This is an example. +This is a better example.

Change 2:

-This is a better example. +This is a better sentence.

Now, make change 2 without change 1. Even if you can split the changes as (1) "an"->"a better"; (2) "example"->"sentence", you get:

 This is an sentence.
When the correct version would be:
 This is a sentence.
But there's no automated way to know this, so you get conflict markers.
	-Daniel
*This .sig left intentionally blank*
Previous: Santi BéjarNext: Rustom Mody
Message 5 of 6 in “how to reorder commits”
  1. Rustom ModyJul 20, 2009
  2. Santi BéjarJul 20, 2009
  3. Rustom ModyJul 20, 2009
  4. Santi BéjarJul 20, 2009
  5. Daniel BarkalowJul 20, 2009
  6. Rustom ModyJul 21, 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.