Git:最简单的压缩方式是对主人进行提交 [英] Git: simplest way of squashing commits on master
问题描述
我有一个托管在GitHub上的项目,我有一个本地克隆。我有一些小提交,我已经推到GitHub。这一切都是使用默认的* master分支完成的。
混淆了merges --squash和rebase等...
什么是最直接的如何将几个历史提交合并到一个提交中,以便将它推到GitHub上?解析方案
在开始之前,您应该确保那么 git status
是干净的(即没有来自该命令的输出)以避免失去工作。做你想做的最简单的方法可能是:
git reset --soft< LAST-COMMIT-THAT'S-OK>
git commit -m'许多压扁的提交'
git push --force原始大师
您应该记住这是重写历史记录(这就是为什么您需要 - force
选项 git push $ c $ ),所以你应该避免这个,如果其他人可能已经克隆或从你的仓库拉。如需更多选择,请参阅此问题及其答案:
Possible Duplicate:
How can I squash my last X commits together using git?
I have a project hosted on GitHub and I have a local clone. I have a load of small commits that I have already pushed up to GitHub. This has all been done using the default *master branch.
I got confused between merge --squash and rebase etc... What is the most straightforward way of combining several historial commits in to one commit so that it pushes up to GitHub?
Before starting, you should make sure that git status
is clean (i.e. there's no output from that command) to avoid losing work. The simplest way to do what you want is probably:
git reset --soft <LAST-COMMIT-THAT'S-OK>
git commit -m 'Many squashed commits'
git push --force origin master
You should bear in mind that this is rewriting history (that's why you need the --force
option to git push
) so you should avoid this if anyone else might have cloned or pulled from your repository. For some more alternatives, see this question and its answers:
这篇关于Git:最简单的压缩方式是对主人进行提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!