git fetch 指令

執行 fetch,可以取得遠端 repo 的最新歷史記錄。取得的送交紀錄會導入在自動建立的分支中,並可以切換這個名為 FETCH_HEAD 的分支。

使用情境

執行 pull,遠端 repo 的內容會自動合併。但是,有時候只是想確認遠端數據庫的內容卻不是真的想合併,在這種情況下,請使用 fetch。

常用指令範例

範例 說明
git fetch 更新目前分支指向的遠端容器
git fetch origin 更新指定遠端容器
git fetch --all 更新所有 remote 底下的分支

語法結構

usage: git fetch [<options>] [<repository> [<refspec>...]]
   or: git fetch [<options>] <group>
   or: git fetch --multiple [<options>] [(<repository> | <group>)...]
   or: git fetch --all [<options>]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --all                 fetch from all remotes
    -a, --append          append to .git/FETCH_HEAD instead of overwriting
    --upload-pack <path>  path to upload pack on remote end
    -f, --force           force overwrite of local branch
    -m, --multiple        fetch from multiple remotes
    -t, --tags            fetch all tags and associated objects
    -n                    do not fetch all tags (--no-tags)
    -p, --prune           prune remote-tracking branches no longer on remote
    --recurse-submodules[=<on-demand>]
                          control recursive fetching of submodules
    --dry-run             dry run
    -k, --keep            keep downloaded pack
    -u, --update-head-ok  allow updating of HEAD ref
    --progress            force progress reporting
    --depth <depth>       deepen history of shallow clone
    --unshallow           convert to a complete repository
    --update-shallow      accept refs that update .git/shallow
    --refmap <refmap>     specify fetch refmap

results matching ""

    No results matching ""