首先,git fetch 有四種基本用法
git fetch →→ 這將更新git remote 中所有的遠(yuǎn)程repo 所包含分支的最新commit-id, 將其記錄到.git/FETCH_HEAD文件中
git fetch remote_repo →→ 這將更新名稱為remote_repo 的遠(yuǎn)程repo上的所有branch的最新commit-id榜掌,將其記錄砸琅。
git fetch remote_repo remote_branch_name →→ 這將這將更新名稱為remote_repo 的遠(yuǎn)程repo上的分支: remote_branch_name
git fetch remote_repo remote_branch_name:local_branch_name →→ 這將這將更新名稱為remote_repo 的遠(yuǎn)程repo上的分支: remote_branch_name 速妖,并在本地創(chuàng)建local_branch_name 本地分支保存遠(yuǎn)端分支的所有數(shù)據(jù)。
FETCH_HEAD: 是一個(gè)版本鏈接,記錄在本地的一個(gè)文件中而芥,指向著目前已經(jīng)從遠(yuǎn)程倉(cāng)庫(kù)取下來的分支的末端版本。
git pull 的運(yùn)行過程:
git pull : 首先膀值,基于本地的FETCH_HEAD記錄棍丐,比對(duì)本地的FETCH_HEAD記錄與遠(yuǎn)程倉(cāng)庫(kù)的版本號(hào),然后git fetch 獲得當(dāng)前指向的遠(yuǎn)程分支的后續(xù)版本的數(shù)據(jù)沧踏,然后再利用git merge將其與本地的當(dāng)前分支合并歌逢。