Skip to main content
added 6 characters in body
Source Link
a06e
  • 20.2k
  • 35
  • 98
  • 177

I have a very messy git history. I want to squash a bunch of older commits (not including the last one).

I know how to squash my last n commits. But this is different. Here I have commits consecutively n1 to n2 which I want to squash into one, while after n2 I have a history of commits that I want to preserve up to the last one.

So, if my current history looks like this:

---- n1 --- n2 -------- m

I want to squash n1 to n2 so it ends up looking like this:

---- n1n2 -------- m

where n1n2 is a single commit containing the squashed contents from n1 to n2.

How should I do this? What are the consequences on the history from n2 to m? 

That is, will the hash of every commit from n2 to m change as a consequence of what I want to do?will the hash of every commit from n2 to m change as a consequence of what I want to do?

I have a very messy git history. I want to squash a bunch of older commits (not including the last one).

I know how to squash my last n commits. But this is different. Here I have commits consecutively n1 to n2 which I want to squash into one, while after n2 I have a history of commits that I want to preserve up to the last one.

So, if my current history looks like this:

---- n1 --- n2 -------- m

I want to squash n1 to n2 so it ends up looking like this:

---- n1n2 -------- m

where n1n2 is a single commit containing the squashed contents from n1 to n2.

How should I do this? What are the consequences on the history from n2 to m? That is, will the hash of every commit from n2 to m change as a consequence of what I want to do?

I have a very messy git history. I want to squash a bunch of older commits (not including the last one).

I know how to squash my last n commits. But this is different. Here I have commits consecutively n1 to n2 which I want to squash into one, while after n2 I have a history of commits that I want to preserve up to the last one.

So, if my current history looks like this:

---- n1 --- n2 -------- m

I want to squash n1 to n2 so it ends up looking like this:

---- n1n2 -------- m

where n1n2 is a single commit containing the squashed contents from n1 to n2.

How should I do this? What are the consequences on the history from n2 to m? 

That is, will the hash of every commit from n2 to m change as a consequence of what I want to do?

edited tags
Link
phd
  • 90.3k
  • 14
  • 137
  • 186
Source Link
a06e
  • 20.2k
  • 35
  • 98
  • 177

git squash older commits (not last one)

I have a very messy git history. I want to squash a bunch of older commits (not including the last one).

I know how to squash my last n commits. But this is different. Here I have commits consecutively n1 to n2 which I want to squash into one, while after n2 I have a history of commits that I want to preserve up to the last one.

So, if my current history looks like this:

---- n1 --- n2 -------- m

I want to squash n1 to n2 so it ends up looking like this:

---- n1n2 -------- m

where n1n2 is a single commit containing the squashed contents from n1 to n2.

How should I do this? What are the consequences on the history from n2 to m? That is, will the hash of every commit from n2 to m change as a consequence of what I want to do?