Squash Commits with Git
来源:互联网 发布:数控双头螺纹编程实例 编辑:程序博客网 时间:2024/06/14 20:00
# switch to master branchgit checkout master# ensure our master is up to dategit pull remoteRepoName master
With the master branch up to date, we'll use git rebase to consolidate:
git rebase -i master
That command will show a list of each commit, as such:
pick fb554f5 This is commit 1pick 2bd1903 This is commit 2pick d987ebf This is commit 3# Rebase 9cbc329..d987ebf onto 9cbc329## Commands:# p, pick = use commit# r, reword = use commit, but edit the commit message# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit# f, fixup = like "squash", but discard this commit's log message# x, exec = run command (the rest of the line) using shell## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#
Edit the summary shown to you by the rebase command, leaving the commit you want to be the main commit as "pick" and changing all subsequent "pick" commands as "squash":
pick fb554f5 This is commit 1squash 2bd1903 This is commit 2squash d987ebf This is commit 3# Rebase 9cbc329..d987ebf onto 9cbc329## Commands:# p, pick = use commit# r, reword = use commit, but edit the commit message# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit# f, fixup = like "squash", but discard this commit's log message# x, exec = run command (the rest of the line) using shell## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#
Write/quit past the editor twice (the second screen would allow you to change the commit message, though I like to keep it the same). At this point, your commits are squashed into one. Run the following command to force a push of the new, consolidated commit:
git push -f
This forced push updates the source repository and our commits have become one. If you had already submitted a pull request at GitHub, the pull request would now show only one commit! With one consolidated commit, code review becomes much, much easier!
- Squash Commits with Git
- 从 git rebase squash 恢复
- git merge --squash的用法
- git merge –squash介绍
- 聊下git merge --squash
- git merge --squash改写提交
- Git 操作之rebase、squash
- Git: Removing commits on remote
- 使用 GPG 签名 Git Commits
- git学习六(git merge --squash)
- Penne with Roasted Butternut Squash and Ham
- git merge的参数--squash的用处
- git merge之squash merge 看日志
- git merge fast-forward squash no-ff
- 「Git」merge –squash介绍
- git -no-ff && --squash && fast-forward
- 如何使用git merge 一系列的commits
- Git合并特定commits 到另一个分支
- Android开发Eclipse中DDMS中Heap使用及GC_EXTERNAL_ALLOC含义
- 原来自己不是什么好人
- Wireshark的过滤规则
- 【巧妙预处理系列】【UVA1330】City game
- TFS使用指南
- Squash Commits with Git
- 如何将MySQL卸载干净
- Jave中System.getProperty()获取的值
- uml_用例图
- 【沟通】线框图:启动开发项目的绝佳方式(ZZ)
- 作业报告13 输出星号图1
- uboot移植---代码重定位
- 为listView添加自定义适配器
- windows7 安装 ffmpeg