[英]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.