十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
Git沖突中g(shù)it checkout高級用法是什么,很多新手對此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

十余年的橋東網(wǎng)站建設(shè)經(jīng)驗(yàn),針對設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)整合營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整橋東建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)公司從事“橋東網(wǎng)站設(shè)計(jì)”,“橋東網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
Git沖突的原因,一般是修改了同一個(gè)文件導(dǎo)致的,這個(gè)文件有可能是別人提交到遠(yuǎn)程倉庫里面,還有就是需要合并這個(gè)文件導(dǎo)致的。
你確定你需要的是哪個(gè)倉庫的文件
git checkout --theirs conflicted_file.txt # 保留遠(yuǎn)端的
git checkout --ours conflicted_file.txt # 保留本地的
然后執(zhí)行add和commit
git add -A
git commit -m "update conflict
獲取遠(yuǎn)端服務(wù)器上的文件,提示沖突了需要合并
# git cherry-pick FETCH_HEAD
* branch refs/changes/85/12385/3 -> FETCH_HEAD
error: 'cherry-pick' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm ' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: cherry-pick failed
查看當(dāng)前倉庫的狀態(tài)
# git status
Not currently on any branch.
You are currently cherry-picking commit 53e5374.
(fix conflicts and run "git cherry-pick --continue")
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
Unmerged paths:
(use "git add ..." to mark resolution)
both modified: file1.txt
用提示的命令執(zhí)行
# git cherry-pick --continue
U file1.txt
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm ' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.
提示file1.txt有更新,確定替換為遠(yuǎn)程倉庫的文件。這里用theirs
git checkout --theirs file1.txt
然后添加到本地倉庫
git add -A
最后繼續(xù)cherry-pick「復(fù)制」
# git cherry-pick --continue
[detached HEAD 8f26ce8] Summary : test git checkout --theirs
Author: Rik
2 files changed, 0 insertions(+), 0 deletions(-)
git ckeckout 和 帶參數(shù)的--ours和 --theirs還是有區(qū)別的。
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)的支持。