threads / discuss / 46324

Dropping a merge from history -- rebase or filter-branch or ...?

Subject: Dropping a merge from history -- rebase or filter-branch or ...?

## tl;dr

2 messages between Jul 7, 2017 and Jul 12, 2017.

replies: 1people: 2as markdown or json

Martin Langhoff· Jul 7, 2017, 21:07 UTC · lore
Hi git-folk!

long time no see! I'm trying to do one of those "actually, please don't" things that turn out to be needed in the field.

I need to open our next "for release" development branch from our master, but without a couple of disruptive feature branches, which have been merged into master already. We develop in github, so I'll call them Pull Requests (PRs) as gh does.

So I'd like to run a filter-branch or git-rebase --interactive --preserve-merges that drops some PRs. Problem is, they don't work!

filter-branch --commit-filter is fantastic, and gives me all the control I want... except that it will "skip the commit", but still use the trees in the later commits, so the code changes brought in by those commits I wanted to avoid will be there. I think the docs/help that discuss "skip commit" should have a big warning there!

rebase --interactive --preserve-merges --keep-empty made a complete hash of things. Nonsense conflicts all over on the merge commits; I think it re-ran the merge without picking up the conflict resolutions we had applied.

The changes we want to avoid are fairly localized -- a specific module got refactored in 3 stages. The rest of the history should replay cleanly. I don't want to delete the module.

My fallback is a manually constructed revert. While still an option, I think it's better to have a clean stat without sizable feature-branch reverts.

cheers,
m
-- 
 martin.langhoff@gmail.com
 - ask interesting questions  ~  http://linkedin.com/in/martinlanghoff
 - don't be distracted        ~  http://github.com/martin-langhoff
   by shiny stuff
Andrew Ardill· Jul 12, 2017, 02:06 UTC · re: Martin Langhoff · lore

Re: Dropping a merge from history -- rebase or filter-branch or ...?

Hi Martin,

From the sound of it you really just want to revert the merge of the pull requests. A really good description of options for this is at https://git-scm.com/blog/2010/03/02/undoing-merges.html

There is also a section there about bringing the changes back in at a future date, depending on how you do the revert.

Does that page describe what you're trying to do?
Regards,
Andrew Ardill
On 8 July 2017 at 07:07, Martin Langhoff <martin.langhoff@gmail.com> wrote:
Show 42 quoted lines
> Hi git-folk!
>
> long time no see! I'm trying to do one of those "actually, please
> don't" things that turn out to be needed in the field.
>
> I need to open our next "for release" development branch from our
> master, but without a couple of disruptive feature branches, which
> have been merged into master already. We develop in github, so I'll
> call them Pull Requests (PRs) as gh does.
>
> So I'd like to run a filter-branch or git-rebase --interactive
> --preserve-merges that drops some PRs. Problem is, they don't work!
>
> filter-branch --commit-filter is fantastic, and gives me all the
> control I want... except that it will "skip the commit", but still use
> the trees in the later commits, so the code changes brought in by
> those commits I wanted to avoid will be there. I think the docs/help
> that discuss  "skip commit" should have a big warning there!
>
> rebase --interactive --preserve-merges  --keep-empty made a complete
> hash of things. Nonsense conflicts all over on the merge commits; I
> think it re-ran the merge without picking up the conflict resolutions
> we had applied.
>
> The changes we want to avoid are fairly localized -- a specific module
> got refactored in 3 stages. The rest of the history should replay
> cleanly. I don't want to delete the module.
>
> My fallback is a manually constructed revert. While still an option, I
> think it's better to have a clean stat without sizable feature-branch
> reverts.
>
> cheers,
>
>
>
> m
> --
>  martin.langhoff@gmail.com
>  - ask interesting questions  ~  http://linkedin.com/in/martinlanghoff
>  - don't be distracted        ~  http://github.com/martin-langhoff
>    by shiny stuff

← back to recent threads