Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm new to git rebase and doing something a bit wacky and stupid. So let's say I have these commits which all modify the same file file.txt

a -> b -> c -> d -> e

I want to just remove commit c.

My strategy for this is to rebase b onto d, keeping d's changes so it reads like this

a -> b -> d -> e

I'm trying to do this with this command

git rebase --rebase-merges --onto c^ c

This results in a failed merge, I've also tried it with -s ours but that fails as well.

This works when each commit modifies a different file, however.

What should I do to satisfy this goal?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
289 views
Welcome To Ask or Share your Answers For Others

1 Answer

In this case, you're almost certainly getting a conflict because there's really a conflict, and there isn't a way to avoid dealing with this. You'll have to resolve the conflict and then run git rebase --continue.

This works when each commit modifies a different file because commits that touch different files don't usually conflict (unless there's a rename or copy).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...