挤压我最后一个X使用Git一起提交 [英] Squash my last X commits together using Git

查看:93
本文介绍了挤压我最后一个X使用Git一起提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Git将我最后一次X提交到一个提交中?

使用解决方案使用<$ c $> git rebase -i< after-this-commit> ,并在第二次和随后的提交中用squash或fixup替换pick,如手册



在这个例子中,< after-this-commit> 可以是SHA1散列值,也可以是当前分支的HEAD的相对位置,从该分支中​​为rebase命令分析提交。例如,如果用户希望查看当前HEAD的5次提交,那么命令是 git rebase -i HEAD〜5

How can I squash my last X commits together into one commit using Git?

解决方案

Use git rebase -i <after-this-commit> and replace "pick" on the second and subsequent commits with "squash" or "fixup", as described in the manual.

In this example, <after-this-commit> is either the SHA1 hash or the relative location from the HEAD of the current branch from which commits are analyzed for the rebase command. For example, if the user wishes to view 5 commits from the current HEAD in the past the command is git rebase -i HEAD~5.

这篇关于挤压我最后一个X使用Git一起提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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