git pull

git

書き方

git pull [--rebase|--ff-only] [<remote> <branch>]

fetchとmergeを一度に行います。だから思わぬマージコミットができるので、--rebaseや--ff-onlyで防ぎます。

よく使うオプション

オプション意味
--rebasereplay your commits on top instead of merging
--ff-onlyrefuse if a merge commit would be needed
--no-rebasemerge, whatever pull.rebase says
--autostashpark local changes for the duration
--prunedrop tracking refs for deleted branches
--depth <n>shallow pull

git pull --rebase origin main

brings in server commits and puts yours on top

git pull --ff-only

updates only when nothing has to be merged

git pull --autostash

pulls even with uncommitted changes in the way

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

読み方

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

よくある質問

Q. git pull は何をしますか。

fetchとmergeを一度に行います。だから思わぬマージコミットができるので、--rebaseや--ff-onlyで防ぎます。

Q. どう打ちますか。

git pull [--rebase|--ff-only] [<remote> <branch>] — 角括弧は省いてよい部分です。

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

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

関連するコマンド

man ページ: man git-pull