Git Rebasing
Comparision: git rebase
, git rebase -i
1. git rebase <branch>
: as an alternative to merging
git rebase <branch>
除了 merging之外的另一選擇
git merge
在協同開發時的問題
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
同時有很多branch,想要 update 到最新的版本的話,我們的 commit 紀錄會有很多是 merge
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
情境A
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
情境B實際使用 git rebase <branch>
遇到 conflict 的處理方式
resolve conflict =>git add
=> git rebase --continue
git rebase -i
: Interactive Rebasing
REWRITE, DELETE, RENAME, or even REORDER commits
Concepts
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- 不是與其他 branch 作用,而是基於 HEAD 所在位置,操作目前所在的 branch 先前的 commits
- 使用
git rebase -i
會讓我們進入一個 interactive mode
- 我們需要指定從多遠以前的 commit 開始做進一步操作我的的 commit
git rebase -i
在 interactive mode 的操作關鍵字
pick
: 使用這個 commit(沒有變動,開始 interactive mode 預設都是 pick)
reword
: 使用這個 commit,但是 編輯 commit 的資訊
drop
: 移除這個 commit
squash
: 使用這個 commit,並且與其他 commit 合併
edit
(沒用過,之後補)
fixup
(沒用過,之後補)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
各種操作關鍵字使用時機
個人經驗分享
drop
使用時機
有某個 commit 不想要了,例如為了要做測試,暫時 hard coded 一些變數,方便後續開發,把這段 hard-coded 的東西單獨做成一個 commit ,可以直接拿掉
squash
使用時機
有一些暫存的 commit(例如午休或下班) ,並不是真的 code 開發的一個階段,可以合併掉
reword
使用時機
要發 PR 時候,發現自己的 commit 亂寫,或是有 typo
GitLens 設定
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
In terminal