简体   繁体   English

Git Interactive变基:将文件压入更改的提交中

[英]Git Interactive rebase: Squash files to the commit they changed

I have the following commits: 我有以下提交:

  • Commit1 affecting file1 and file2 Commit1影响file1file2
  • Commit2 affecting file2 and file3 Commit2影响file2file3
  • Clean up commit affecting file1 , file2 and file3 (in this commit I only reformat a few lines) Clean up commit影响file1file2file3提交(在此提交中,我仅重新格式化了几行)

Is it possible with git rebase to squash the Clean up commit such that changes to file1 are applied to Commit1 and changes to file2 and file3 are applied to Commit2 ? git rebase是否可以Commit1Clean up commit ,以便Commit1 file1更改应用于Commit1并将对file2file3更改应用于Commit2 That is changes should be split according to files and then be applied to the last commit the file was changed. 也就是说,应根据文件拆分更改,然后将其应用于文件更改的最后一次提交。

You have to do this manually. 您必须手动执行此操作。 You either have to split up commit3 into commit3 and commit4 and then squash them individually, or you can set commit1 to edit in the interactive rebase and commit3 to squash into commit2, then when editing commit1 you apply the changes of commit3 you want to have in and then continue rebasing. 您要么必须将commit3拆分为commit3和commit4,然后分别压缩它们,要么可以将commit1设置为在交互式rebase中进行edit ,而将commit3设置为将其压缩为commit2,然后在编辑commit1时应用要包含的commit3更改然后继续进行基地调整。 The rest should work without problem then, as the changes are applied already. 其余的应该可以正常工作,因为更改已经应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM