Git:最简单的压缩方式是对主人进行提交 [英] Git: simplest way of squashing commits on master

查看:109
本文介绍了Git:最简单的压缩方式是对主人进行提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:


我有一个托管在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


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆