I have 2 branches, master
& feature
. Master occasionally receives small tweaks that are needed to go live quickly. Once these tweaks are done, master
is rebased into feature
so that feature is kept up to date.
The files changed on master are generally not related to the bulk of the development on feature
but I've been getting a high number of complicated 3 way merge conflicts.
After looking at the commit log of feature
, I've found the problem to be several duplicates and I'm attempting to solve it with an interactive rebase.
My question is:
Is this the best solution for the problem, and if so can I just drop the duplicates and essentially build the history how I expect it to look? Also which duplicates would I drop, higher(older original) or lower (newer duplicates).
Abstract listing taken from git rebase master -i
:
pick 0eb277c Commit A
pick ced2556 Commit B
pick 640e049 Commit C
pick b248ff7 Commit D
pick 9903094 Commit E
pick ebc279d Commit A
pick 313385b Commit F
pick 0d55178 Commit G
pick c8f09f9 Commit H
pick e877be3 Commit I
pick 9859aa0 Commit J
pick c3c8e0f Commit K
pick 8abc68c Commit L
pick 84a5c89 Commit A
pick 30570e4 Commit B
pick 937ff2f Commit C
pick 8e6d911 Commit D
pick 1dd3a09 Commit E
pick fe79288 Commit F
pick 9e790bb Commit G
pick 0924916 Commit H
pick 90d59d7 Commit I
pick ba06c55 Commit J
pick 7452fad Commit K ** Dupes end here** and features then has 30+ more commits.
pick d1dca3d Commit M
pick 6c85f76 Commit N
pick ad53b78 Commit O
pick f166471 Commit P
To modify older or multiple commits, you can use git rebase to combine a sequence of commits into a new base commit. In standard mode, git rebase allows you to literally rewrite history — automatically applying commits in your current working branch to the passed branch head.
Rebasing a branch on another "re-applies" (fairly smartly, these days) the commits of the currently checked out branch on top of the tip of the target. So, yes, if you do it over and over again then you will keep your current branch up to date.
You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called. You can run git rebase --skip to completely skip the commit.
To remove the duplicate commits you must go through the list generated by git rebase master -i
and drop the duplicates by navigating up and down the list using the arrow keys pressing d on the commits you want to drop
.
(master
can be replaced with a commmit hash or any valid re-base point)
Once you have deleted all the duplicates and have a commit list that looks how you expect the history to look, exit the rebase screen by pressing esc and typing !wq
and pressing enter.
The re-base will then continue and apply the list of commits you pick
ed onto your re-base point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With