Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我的分支中有 100 个提交,我已经工作了 3 周。偶尔(每天,真的)我从 origin/master 中提取并将其合并到我的分支中。
我怎样才能(轻松地)将我所有的提交压缩成一个提交而不弄乱历史?如果我以某种方式将所有提交压缩为一个,那么当我的拉取请求移动到源/主时,我会破坏合并的源/主拉吗?
“挤压”和“保存历史”在术语上几乎是直接对立的。
如果您的意思是要进行一次提交,其中仅包含您的更改而不包括来自上游 master 的更改,您可能希望rebase进入 origin/master,然后从那里压缩。您可以通过一次交互式 rebase 调用来完成所有这些操作:
rebase
git fetch origin git rebase -i origin/master
然后将第一行之后的所有行从pick更改为squash。
pick
squash