広告

暗号資産取引所の登録特典

登録するだけで受け取れる特典です。条件は各取引所の告知をそのまま載せています。

git fetch

git

書き方

git fetch [--all] [--prune] [<remote> [<branch>]]

リモートの新しいコミットを受け取るだけで、自分のファイルやブランチは動きません。反映にはmergeやrebaseが必要で、サーバーで消えたブランチは--pruneまで残ります。

よく使うオプション

オプション意味
--allfrom every remote
--prunedelete tracking refs whose branch is gone on the server
--tagsalso fetch tags
--unshallowfill in the history a --depth clone left out
--depth <n>deepen a shallow clone by n commits
-fupdate a ref even when it is not a fast-forward

例

git fetch --all --prune

refreshes every remote and clears dead branches

git fetch origin main

updates origin/main without touching your files

git fetch --unshallow

turns a shallow clone into a full one

取り消しに何通りもあるのが混乱のもとです — ブランチの指す先を動かすのと、打ち消すコミットを積むのは別です。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Qgit fetch は何をしますか。

リモートの新しいコミットを受け取るだけで、自分のファイルやブランチは動きません。反映にはmergeやrebaseが必要で、サーバーで消えたブランチは--pruneまで残ります。

Qどう打ちますか。

git fetch [--all] [--prune] [<remote> [<branch>]] — 角括弧は省いてよい部分です。

Qよく使うオプションはいくつですか。

ここにまとめたのは6個です。全部は man git にあります。このコマンドはgitの仲間です。

関連するコマンド

man ページ: man git-fetch