git pull
git
Usage
git pull [--rebase|--ff-only] [<remote> <branch>]Runs fetch and merge in one step, which is where surprise merge commits come from; --rebase or --ff-only prevents them.
Common flags
| Flag | Meaning |
|---|---|
| --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 |
Examples
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
The confusion is that undo has several shapes — moving where a branch points is not the same as adding a commit that reverses it.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does git pull do?
Runs fetch and merge in one step, which is where surprise merge commits come from; --rebase or --ff-only prevents them.
Q. How do I type it?
git pull [--rebase|--ff-only] [<remote> <branch>] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
6 are listed here; the full set is in man git. This command sits under git.
Related commands
man page: man git-pull