Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

git pull vs git fetch 差異詳解:自動合併 vs 手動審查合併

編輯:Linux 教學

git pull

從遠端獲取最新版本並 自動合併 到當前分支。

git pull origin master

git fetch

從遠端獲取最新版本到本地 不自動合併,方便人工比對差異再決定合併策略。

# 方式一
git fetch origin master
git log -p master..origin/master   # 查看差異
git merge origin/master            # 手動合併

# 方式二:抓取到臨時分支
git fetch origin master:temp
git diff temp                      # 比對差異
git merge temp                     # 合併

建議:需審查變更時用 fetch + diff/log + merge;確定無衝突可直接 pull。

Copyright © Windows教程網 All Rights Reserved