git pull
git
書き方
git pull [--rebase|--ff-only] [<remote> <branch>]fetchとmergeを一度に行います。だから思わぬマージコミットができるので、--rebaseや--ff-onlyで防ぎます。
よく使うオプション
| オプション | 意味 |
|---|---|
| --rebase | replay your commits on top instead of merging |
| --ff-only | refuse if a merge commit would be needed |
| --no-rebase | merge, whatever pull.rebase says |
| --autostash | park local changes for the duration |
| --prune | drop tracking refs for deleted branches |
| --depth <n> | shallow pull |
例
git pull --rebase origin mainbrings in server commits and puts yours on top
git pull --ff-onlyupdates only when nothing has to be merged
git pull --autostashpulls 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