iT邦幫忙

2017 iT 邦幫忙鐵人賽
DAY 10
0
自我挑戰組

Git學習筆記系列 第 10

git pull 到底?

上一篇我們曾經使用到git pull把遠端主機上的版本拿到現在的branch上

且會自動合併有衝突的檔案

我們只要去針對那些被加上標準的衝突解決標記的檔案來解決衝突

但其實

git pull等同於git fetch後再 git merge origin/master

回到上篇push失敗的狀況

我們就要先將遠端的物件抓回來,執行git fetch

git fetch

git fetch [<options>] [<repository> [<refspec>…​]]
git fetch [<options>] <group>
git fetch --multiple [<options>] [(<repository> | <group>)…​]
git fetch --all [<options>]

這時候會將遠端最新的物件取回到本地追蹤分支(origin/master)上

git fetch官方文件

再來就可以透過 git merge origin/master 來將本地追蹤分支合併到master分支上

git merge

git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
	[-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
	[--[no-]allow-unrelated-histories]
	[--[no-]rerere-autoupdate] [-m <msg>] [<commit>…​]
git merge <msg> HEAD <commit>…​
git merge --abort

merge後的步驟就跟git pull後的步驟一樣

手動去把有衝突的檔案解決衝突的狀況

再commit後就可以push到遠端版本庫了

git merge官方文件


上一篇
Git 小劇場 解決衝突
下一篇
重設遠端版本庫位址
系列文
Git學習筆記31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言