1

I did a mess with my features branches. What I had:

master:  A - B
               \
branch1:        E - F
                     \
branch2:              G - H        

And then

  • I squashed and merge branch1 to the main
  • Added a few commits on the main
  • Rebase my branch2 on the main
master:  A - B - EF - I - J
                           \      
branch2:                    E - F - G - H   

Is there a fast way to clean my branch2, and find the commits that exist there, without the commits from branch1?

Guildenstern
  • 2,179
  • 1
  • 17
  • 39
Chana Drori
  • 159
  • 1
  • 1
  • 10

1 Answers1

3

I'd suggest to interactively rebase the last 4 commits on branch2, and deleting the two branch1 commits from the "todo" list:

git checkout branch2
git rebase -i --no-ff HEAD~4

In the editor remove the 2 commits from branch1, then save and close the editor.

In case the editor appearing is vi and you're not familiar with it:

  • Press the [Esc] key to make sure you're not in insert mode
  • Use the arrow keys to move the cursor to a line you want to delete
  • Type dd on the keyboard to delete a line.
  • When you're done deleting lines, type this to save and quit: :wq
Jay
  • 3,640
  • 12
  • 17