我尝试rebase -i
在我的历史记录中发生的一些提交。说我有这样的日志:
* 5e32fb0 (HEAD -> master) Add latest feature
* 106c31a Add new feature
* 2bdac33 Add great feature
...100 other commits...
* 64bd9e7 Add test 3
* 3e1066e Add test 2
* 26c612d Add test 1
* 694bdda Initialize repo
我想要压缩3次测试提交。在这种情况下,git rebase -i HEAD~106
并不实用。我正在寻找的是git rebase -i 64bd9e7:26c612d
。
git是否有这种行为,如果是这样,我该如何使用它?
我看了this post,但它没有回答我的问题。
答案 0 :(得分:4)
只需使用[15:12:32] I/launcher - Running 2 instances of WebDriver
[15:12:36] I/testLogger -
------------------------------------
[15:12:36] I/testLogger - [chrome #11] PID: 12332
[chrome #11] Specs: C:\Users\JeanB\work_projects\dealflo-cwf-ux\e2e\features\footer-component.feature.ts
[chrome #11]
[chrome #11] (node:12332) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[chrome #11] [15:12:33] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[chrome #11] [15:12:36] I/runnerCli - Unexpected token import
[15:12:36] I/testLogger -
[15:12:36] E/launcher - Runner process exited unexpectedly with error code: 1
[15:12:36] I/launcher - 1 instance(s) of WebDriver still running
[15:12:37] I/testLogger -
------------------------------------
[15:12:37] I/testLogger - [firefox #01] PID: 14720
[firefox #01] Specs: C:\Users\JeanB\work_projects\dealflo-cwf-ux\e2e\features\footer-component.feature.ts
[firefox #01]
[firefox #01] (node:14720) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[firefox #01] [15:12:33] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[firefox #01] [15:12:37] I/runnerCli - Unexpected token import
[15:12:37] I/testLogger -
[15:12:37] E/launcher - Runner process exited unexpectedly with error code: 1
[15:12:37] I/launcher - 0 instance(s) of WebDriver still running
[15:12:37] I/launcher - chrome #11 failed with exit code: 1
[15:12:37] I/launcher - firefox #01 failed with exit code: 1
[15:12:37] I/launcher - overall: 2 process(es) failed to complete
[15:12:37] E/launcher - Process exited with error code 100
并仅压缩这些提交。
rebase -i
如果您有很多提交,我建议您查看git rebase -i <main_branch>
# Now just add `s` in front of all the commits you want to squash
-
rebase --onto
注意:重写历史记录是一项高级操作,因此请小心谨慎。
答案 1 :(得分:3)
为了压缩这三个提交,您需要重新编写整个存储库的历史记录。也就是说,将修改那些测试提交之后提交的所有提交哈希值。在我看来,最直接的方法是:
64bd9e7
的临时分支和结帐。64bd9e7
之后立即将其重置为提交。