问题描述
不好意思,但是我有这样的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 replace_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
有没有一种方法可以解决此问题,或者有一种更好的方法可以做到这一点?
解决方法
啊!我尝试了不带“ ^”的方法,并且有效!
git cherry-pick 3417248ab0953d715b3318f64635a825473bf73d..fc9ab1fe1cfc2ac1e82e2de18a4244d94a7bb89f