Git Learning — 3

Rose Chang Dycd
Feb 14, 2023

Newbie Git Notes

About Rebase

Command: git rebase <BranchName>
(HEAD分支要採到 <BranchName> 分支頭上)

Steps:

  1. Commit# where HEAD is located will “copy” to the top of the branch to be adopted. (HEAD所在commit# 會”複製一份”到要採的分支上面)

2. The branch/HEAD sticker will be moved to the “copied” commit#.
(其分支/HEAD貼紙會移動到”複製”的commit#)

3. Complete. The graph visual effect becomes one line. The old commit# is hidden due to no branch/HEAD sticker on it. (完成。視覺效果會變成一條線,原分支因無人看管 (沒有HEAD也沒有分支貼紙)會自動隱藏。)

Pros and Cons

Pro: The graph lines are clean to avoid too many branches.
(視覺線條簡潔、避免過多分支)

Con: The history commit description will change as a future reference.
(無法日後追查,因歷史紀錄會改變)

Merge v.s. Rebase:

  1. If history is important for the team, then use Merge.
    (如果歷史紀錄對團隊很重要 → 用 merge)
  2. If visual cleaning is important for the team, then use Rebase.
    (如果視覺簡潔很重要 → 用 rebase)

--

--