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