请原谅我糟糕的git,我有一个git日志,如下所示:
commit fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89f
Author:
Date:
message 4
commit 3417248ab0953d715b3318f64635a825473bf73d
Author:
Date:
message 3
commit da223a0b1e333a935b548a93f00263bb5b554cf7
Author:
Date:
message 2
commit 1910a6cd9586e905258c6c9dcace2a7800a55f26
Author:
Date:
message 1我想保留最早的提交,用不同的提交代替第二次提交,然后将第三次和第四次提交放在上面。例如:
旧: fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89f 3417248ab0953d715b3318f64635a825473bf73d da223a0b1e333a935b548a93f00263bb5b554cf7 1910a6cd9586e905258c6c9dcace2a7800a55f26
新增: fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89f 3417248ab0953d715b3318f64635a825473bf73d replacement_commit 1910a6cd9586e905258c6c9dcace2a7800a55f26
这就是我是如何“老”的
#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以下是我尝试进行更改的方式
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它不起作用。输出:
-> % 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有没有办法解决这个问题,或者有更好的办法呢?
发布于 2020-10-03 07:08:03
阿!我试过了,没有"^“,它起作用了!
git cherry-pick 3417248ab0953d715b3318f64635a825473bf73d..fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89fhttps://stackoverflow.com/questions/64179161
复制相似问题