Git合并提交 [英] Git merge commits

查看:115
本文介绍了Git合并提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git的新手(并且非常享受!)。在一个新分支开发的同时,我继续承诺我的应用程序的各种开发状态。现在我必须检查它的审查,但不希望一切都在不同的提交(不同的评论和ID)。

I'm new to git (and enjoying it a lot!). While developing in a new branch, I kept committing the various development 'states' of my application. Now I have to check it in for review but didn't want everything to go in different commits (different comments and ids).

我怎么能推动所有如果它是第一次改变?

How can I do a push of all changes as if it was the first time?

推荐答案

git rebase -i HEAD~5

允许您以交互方式选择最后5次提交中的哪一个加入到一个中;打开我的脑袋,它打开编辑器,像这样的东西

allows you to interactively select which of the 5 last commits to join into one; off the top of my head it opens the editor with something like this

pick xxxx commit1
pick xxxx commit2
pick xxxx commit3
pick xxxx commit4
pick xxxx commit5

您改变这进入

you change this into

pick xxxx commit1
squash xxxx commit2
squash xxxx commit3
squash xxxx commit4
pick xxxx commit5

导致剩下两个提交:第一个合并提交1 - 4,并承诺5(最新的一个),这是孤立的

which results in two commits being left: first one that has combined commits 1 - 4, and commit 5 (the newest one) which is left alone

这篇关于Git合并提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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