简体   繁体   English

如何加入两个推送的提交?

[英]How can I join two pushed commits?

How can I join two pushed commits? 如何加入两个推送的提交?

For example: I have a commit fixing a typo and a commit changing a text file. 例如:我有一个修正打字错误的提交和一个改变文本文件的提交。 I want to join both and keep only the one which says "changing a text file" on the commit log. 我想同时加入两者,并只在提交日志中保留一个“正在更改文本文件”的内容。

How can I do it? 我该怎么做?

Generally, you can use git rebase -i and fixup to rewrite the history and merge commit 2 into commit 1. 通常,您可以使用git rebase -ifixup重写历史记录并将提交2合并到提交1中。

Because you already pushed the changes, beware that it is generally not recommended to rewrite the history after the changes has been pushed to a remote repository, because other clients may have already downloaded the changes and you may cause troubles with future updates. 因为您已经推送了更改,所以请注意,通常不建议在将更改推送到远程存储库后重写历史记录,因为其他客户端可能已经下载了更改,并且可能会给以后的更新带来麻烦。

If you are fully aware of what you are doing, use rebase to rewrite the history, and push the changes with the --force flag: git push -f . 如果您完全知道自己在做什么,请使用rebase重写历史记录,并使用--force标志推送更改: git push -f

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

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