GitLab
  • Introduction
  • 初步了解
  • 安裝
  • 資料庫使用方式(postgreSQL)
  • 一些程式碼
  • Gitlab CI
  • Learn Git
    • Git 指令
    • 第一堂課 - 介紹git commit
    • 第二堂課 - git 的 branch
    • 第三堂課 - branch 以及 merge
    • 第四堂課 - git rebase
    • 第五堂課 - 在 git 中前後移動
    • 第六堂課 - 相對引用
    • 第七堂課 - "~" 符號
    • 第八關 - 取消 git 的修改
    • 第九堂課 - 移動 commit
Powered by GitBook
On this page

Was this helpful?

  1. Learn Git

第三堂課 - branch 以及 merge

太好了! 我們已經知道怎麼使用 commit 和 branch 了。接下來要學的一招是如何合併(merge)兩個不同 branch 的工作。這讓我們可以建立一個新的 branch ,並且在上面開發新功能,然後合併回 master branch。

git merge是我們要學習 merge 的第一個方法。該 merge 會產生一個特殊的 commit,它包含兩個唯一 parent commit。一個 commit 如果有兩個 parent commit 的話,那就表示:「我想把這兩個 parent commit 本身及它們的 所有的 parent commit 都包含進來。」

有圖有真相,看看下面的圖就明白了。

語法如下:

git branch bugFix
git commit
git checkout bugFix
git commit
git checkout master
git merge bugFix
Previous第二堂課 - git 的 branchNext第四堂課 - git rebase

Last updated 5 years ago

Was this helpful?