[英]Squash Commits in Git Desktop
我正在尝试使用我已经推送到 GitHub 的分支将 6 次提交压缩为一次提交。
我尝试通过命令行执行此操作,但我一直收到空操作而不是该分支的提交。
有没有一种方法可以通过 GitHub 桌面执行此操作更有意义?
如果可能,请逐步提供;
我不熟悉将 GitHub 用于协作目的,我的知识范围并不超过 git add、commit 和 push。
要执行 git squash,请按照以下步骤操作:
// X is the number of commits you wish to squash, in your case 6
git rebase -i HEAD~X
压缩提交后 - 选择s
表示压缩 = 它将所有提交合并为一个提交。
您还可以使用 --root 标志以备不时之需
尝试: git rebase -i --root
- 根
Rebase all commits reachable from <branch>, instead of limiting them with
an <upstream>.
This allows you to rebase the root commit(s) on a branch.
When used with --onto, it will skip changes already contained in `<newbase>`
(instead of `<upstream>`) whereas without --onto it will operate on every
change. When used together with both --onto and --preserve-merges, all root
commits will be rewritten to have `<newbase>` as parent instead.`
Thoughtbot 的这篇文章可能会帮助您通过命令行完成它。 确切地知道您在做什么可能比依赖 Git 的 GUI 工具更好。 从长远来看,这将使您受益。
https://thoughtbot.com/blog/git-interactive-rebase-squash-amend-rewriting-history
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.