第四堂課 - git rebase

rebasing是 merge branch 的第二種方法。rebasing 就是取出一連串的 commit,"複製"它們,然後把它們接在別的地方。

雖然聽起來難以理解,rebasing 的優點是可以建立更線性的 commit history。假如只允許使用 rebasing 的話,則我們的 repo 中的 commit log 或者是 commit history 會更加簡潔好看。

讓我們親身體會一下...

破關提示:

想完成這一關,執行以下操作:

  • 建立bugFixbranch

  • commit 一次

  • 切換回 master branch 再 commit 一次

  • 再次切換到 bugFix branch,接著 rebase bugFix 這個 branch 到 master branch 上

祝你好運啦!

語法如下:

git branch bugFix
git checkout bugFix
git commit
git checkout master
git commit
git checkout bugFix
git rebase master

Last updated