Background
I have a GitHub project I'm currently working on and at the same time I'm learning Git. Today I've read about squashing with rebase
command and wanted to try it on some commits that I've pushed a few days ago.
The commits I want to work with are 2b16710
and 32fef8e
. On my local repository master branch log looks like this:
* f49573f - (21 hours ago) [#12] Add durability icons - KamilPacanek (origin/enh/12-durability, enh/12-durability)
* 1c9fec4 - (21 hours ago) [#12] Move reactor parts handling to ReactorPanel - KamilPacanek
* d68bebe - (2 days ago) Merge branch 'enh/7-introducing-clock-ticks' - KamilPacanek (HEAD -> master, origin/master)
|\
| * 2b16710 - (2 days ago) [#7] Refactors - KamilPacanek
| * 32fef8e - (2 days ago) [#7] Implements game ticks - KamilPacanek
|/
* f699930 - (2 days ago) Merge branch 'enh/28-oper-icons-rework' - KamilPacanek
|\
| * ffb3672 - (2 days ago) [#28] Reactor icon animates when reactor is working - KamilPacanek
As you can see, after the commits I've made a feature branch (enh/12-durability
).
What I was trying to do
I've tried the following approach - checkout
the master, did an experimental branch and executed following commands to squash the commits.
git rebase -i f699930
I've marked the 2b16710
with fixup
and it resulted in the following tree:
* a7641cc - (2 days ago) [#7] Implements game ticks - KamilPacanek (HEAD -> exp-squash)
| * f49573f - (21 hours ago) [#12] Add durability icons - KamilPacanek (origin/enh/12-durability, enh/12-durability)
| * 1c9fec4 - (21 hours ago) [#12] Move reactor parts handling to ReactorPanel - KamilPacanek
| * d68bebe - (2 days ago) Merge branch 'enh/7-introducing-clock-ticks' - KamilPacanek (origin/master, master)
| |\
|/ /
| * 2b16710 - (2 days ago) [#7] Refactors - KamilPacanek
| * 32fef8e - (2 days ago) [#7] Implements game ticks - KamilPacanek
|/
* f699930 - (2 days ago) Merge branch 'enh/28-oper-icons-rework' - KamilPacanek
|\
| * ffb3672 - (2 days ago) [#28] Reactor icon animates when reactor is working - KamilPacanek
After that, I've made some diffs to ensure that a7641cc
contains the same changes as these two squashed ones and it did.
Next, I've tried to figure out how to merge these changes to my master
and finally push to origin
to rewrite the history, BUT:
- I'm worried about the
enh/12-durability
branch - I'm the only contributor so I have full control over the process but first I must know how to apply new history to the branch (or maybe I didn't have to as I'm going to merge it with master after work is done) - I don't know why it keeps showing me the tree in such way - I thought the squashing rewrites the commits so instead of two I will have one. So I think I need an explanation whether my understanding is wrong or it will look like that after some force push.
I wanted to achieve something like this (notice there is no 2b16710
commit):
* f49573f - (21 hours ago) [#12] Add durability icons - KamilPacanek (origin/enh/12-durability, enh/12-durability)
* 1c9fec4 - (21 hours ago) [#12] Move reactor parts handling to ReactorPanel - KamilPacanek
* d68bebe - (2 days ago) Merge branch 'enh/7-introducing-clock-ticks' - KamilPacanek (HEAD -> master, origin/master)
|\
| * 32fef8e - (2 days ago) [#7] Implements game ticks - KamilPacanek
|/
* f699930 - (2 days ago) Merge branch 'enh/28-oper-icons-rework' - KamilPacanek
|\
| * ffb3672 - (2 days ago) [#28] Reactor icon animates when reactor is working - KamilPacanek
Am I on the right track? I have feeling that I need to cherrypick some of the commits to make it right.. but I don't know.