git 分支合併 分支衝突

2021-10-25 13:51:28 字數 1382 閱讀 2816

分支合併的不同使用場景:

合併指定分支到當前分支

git merge 

當多分枝協作時,往往會產生一些衝突;

你的本地有兩個分支master/dev,指向同乙個版本,起始時狀態相同,且只有乙個readme.txt檔案。

你在master上新增一段hello master,且add/git commit

然後切換到dev上新增了一段hello dev,且add/commit

此時,如果你想要合併devmaster上,就會發生分支合併的衝突

當執行git merge

進行分支合併時,如果產生以下衝突,需要手動合併之後再提交;

$ git merge feature1

auto-merging readme.txt

conflict (content): merge conflict in readme.txt

automatic merge failed; fix conflicts and then commit the result.

# when resolve the conflict, can exec the following commands:

# git add

# git commit -m "descibe content"

# this command can show the commit graph.

# git log --graph

當建立乙個新的分支命名為dev,然後新增乙個readme.txt檔案到這個分支,切換到master做合併操作,執行:

# to execute merege command on master branch.

git merge dev

如果此時刪除了dev分支, 那麼分支的資訊就消失了;這種合併模式稱為fast-forward模式

如果使用--no-ff模式,表示禁用ff模式,執行:

# to execute merge command using --no-ff mode on master branch.

git merge --no-ff -m "describe message about this commit" dev

Git合併分支或者衝突

假設衝突檔案是 test testcase.php 總結,大部分情況下,都推薦使用第5種,使用分支的方法,來管理檔案修改衝突。大致步驟 1 在a分支,複製a到b分支 伺服器已經存在 git checkout b b 2 同步 git pull r origin b 3 解決衝突 4 提交 git a...

git 分支合併衝突處理(conflict)

基於同個原始分支後,兩個分支同步開發,最後合併 合併兩個分支 branch1 2可以是分支名,也可以通過指定版本的sha1 16進製制的前7個位 git merge branch1 branch2 解決衝突通過git diff來比較兩個分支的不同點,手動合併 比較兩個分支 預設比較所有的不同 git...

git分支合併,及衝突處理

寫的有點亂,只是做了乙個總結 方法一 git checkout b test 方法二 git branch test git checkout testgit branchgit push origin testgit branch d testgit push origin test顯示結果為 m...