完整學會Git的24堂課D3

完整學會Git的24堂課D3

完整學會Git的24堂課D3

@合併分支

git merge branch_name會將指定分支合併至現在分支

合併後原分支仍存在,可使用git branch -d branch_name刪除

反悔時可使用:

git reset — hard HEAD 中間hard表示資料夾檔案也要回覆

以上為master 與分支沒有檔案衝突時會預設使用的方法(Fast-forward merge),他運作上不會生成新分支,只是讓master的紀錄到分支的head

@新節點合併(3 way merge)

git merge — no-ff branch_name 會將branch_name的紀錄最新內容commit 到master,在master產生新節點,而branch不受影響。

@衝突發生時

當master 檔案有做修改,且branch也做修改,要merge時會產生衝突,須先手動解決衝突後在git add ./ git commit -m “why”後刪除branch,git branch -d branch name.

@無名分支衝突解決

概念:先命名分支,移至master 在merge

git branch name_the_nonamebranch

git checkout master

git branch name_the_nonamebranch #git

Comments

Loading comments…

Leave a Comment