好的,我做了一些实验并运行了一段时间,我想出了一个解决方案。
如果那些具有更好git-fu的人能够验证这确实是一种好的/安全的方法,这将是很有帮助的。
我放弃了更改提交消息以反映更改的尝试。我确实找到了这样做的方法,但现在我对这一切对存储库的影响有了更好的理解,所以我选择不担心这个细节。
这个命令似乎适用于压缩一系列不是从头部开始的提交。
git rebase -Xtheirs --onto 80ab2939 7d84151f
这里的关键是
-Xtheirs
因为至少在我的应用程序中,它会导致冲突。请注意,我的案例很特殊,因为它依赖于已知的提交消息模式,并且文件是相同的。
我在这段历史上运行了以上内容
6add12a1 - Update the package from handle
70f438be - Updated client version to 0.15.0.2152 and next version to 0.15.0.2153
7d84151f - Updated client version to 0.15.0.2151 and next version to 0.15.0.2152
eace113b - Updated client version to 0.15.0.2150 and next version to 0.15.0.2151
e72624dd - Updated client version to 0.15.0.2149 and next version to 0.15.0.2150
85d15b6c - Updated client version to 0.15.0.2148 and next version to 0.15.0.2149
a4e140cd - Updated client version to 0.15.0.2147 and next version to 0.15.0.2148
ffb18892 - Updated client version to 0.15.0.2146 and next version to 0.15.0.2147
ebd33432 - Updated client version to 0.15.0.2145 and next version to 0.15.0.2146
f0727ca7 - Updated client version to 0.15.0.2144 and next version to 0.15.0.2145
80ab2939 - Adjust balance if FB rewards popup is shown
0c04a1d7 - Updated client version to 0.15.0.2143 and next version to 0.15.0.2144
这会产生一些输出:
First, rewinding head to replay your work on top of it...
Auto-merging resources/plists/jks-info.plist
Auto-merging resources/next_build_version.txt
[detached HEAD 8beac4c7] Updated client version to 0.15.0.2152 and next version to 0.15.0.2153
Date: Mon Mar 4 02:01:15 2019 -0800
2 files changed, 2 insertions(+), 2 deletions(-)
Committed: 0001 Updated client version to 0.15.0.2152 and next version to 0.15.0.2153
[detached HEAD 4ede3d58] Update the package from handle
Date: Mon Mar 4 02:03:09 2019 -0800
1 file changed, 4 insertions(+), 2 deletions(-)
Committed: 0002 Update the package from handle
All done
但由此产生的历史(
git log
)很好。
4ede3d58 - Update the package from handle
8beac4c7 - Updated client version to 0.15.0.2152 and next version to 0.15.0.2153
80ab2939 - Adjust balance if FB rewards popup is shown
0c04a1d7 - Updated client version to 0.15.0.2143 and next version to 0.15.0.2144
e89fd769 - Updated client version to 0.15.0.2142 and next version to 0.15.0.2143
我的最后一步是强制推送,因为已经推送了提交。请注意,强制推送将重写您的历史记录。我实际上使用
git push --force-with-lease
为了安全起见。