When running actions like cherry-pick
, rebase
or merge
, git
keeps track of several info on the base commit.
It looks like a reasonable safety to prevent the base commit from being modified.
I would advise you to somehow finish your cherry-pick
, and then use rebase -i
to modifiy the sequence of commits you want.
If we use the following names :
--*--*-- ... --A--B <- HEAD
\
*-- ... X <- cherry-picked commit
# you are currently on B, you run :
git cherry-pick X
If you wish to reach :
--*--*-- ... --A--B'--X' <- cherry-picked version of X
\ ^
\ a modified version of B
*-- ... X
you can :
# add the modifications intended for B' :
git add -p [files]
# create a regular commit, using "git commit" :
git commit
--*--*-- ... --A--B--C
# complete the cherry-pick process :
git add [files with solved conflicts]
git cherry-pick --continue
--*--*-- ... --A--B--C--X'
# use 'rebase -i A' to squash B and C into one commit
git rebase -i A
# set the rebase actions to "squash C into B"
# the result should be what you expect :
--*--*-- ... --A--B'--X'