Excuse my bad git but I had a git log like this:
commit fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89f
Author:
Date:
message 4
commit 3417248ab0953d715b3318f64635a825473bf73d
Author:
Date:
message 3
commit da223a0b1e333a935b548a93f00263bb5b554cf7
Author:
Date:
message 2
commit 1910a6cd9586e905258c6c9dcace2a7800a55f26
Author:
Date:
message 1
I wanted to keep the earliest commit, do a different commit in place of the second commit and then put the third and fourth commits on top of that. e.g.
Old: fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89f 3417248ab0953d715b3318f64635a825473bf73d da223a0b1e333a935b548a93f00263bb5b554cf7 1910a6cd9586e905258c6c9dcace2a7800a55f26
New: fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89f 3417248ab0953d715b3318f64635a825473bf73d replacement_commit 1910a6cd9586e905258c6c9dcace2a7800a55f26
Here's how I got to "Old"
#changes
git add .
git commit -m "message1"
#changes
git add .
git commit -m "message2"
#changes
git add .
git commit -m "message3"
#changes
git add .
git commit -m "message4"
git push
Here is how I tried to make my changes
git pull
git reset 1910a6cd9586e905258c6c9dcace2a7800a55f26
git reset #removes all the later commits from staging
#make changes
git add .
git commit -m "replacement_commit"
#now to cherry pick the other two (which have already been pushed to a repository for this branch)
git cherry-pick 3417248ab0953d715b3318f64635a825473bf73d^..fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89f
It doesn't work. Output:
-> % git cherry-pick 3417248ab0953d715b3318f64635a825473bf73d^..fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89f
On branch my_branch
Cherry-pick currently in progress.
nothing to commit, working tree clean
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:
git commit --allow-empty
and then use:
git cherry-pick --continue
to resume cherry-picking the remaining commits.
If you wish to skip this commit, use:
git cherry-pick --skip
Is there a way I can fix this or a better way I can be doing this?
Ah! I tried it without "^" and that worked!