Linux command
git-pull 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Pull from origin
git pull
Pull from specific remote
git pull [remote]
Pull specific branch
git pull [remote] [branch]
Pull with rebase
git pull --rebase
Pull all remotes
git pull --all
Pull without committing merge
git pull --no-commit
Pull with fast-forward only
git pull --ff-only
说明
git pull fetches from a remote and integrates the changes with the current branch. It is equivalent to running `git fetch` followed by `git merge`, or `git rebase` when the `--rebase` option is used. Pull strategies vary by workflow. Some teams prefer merge (preserving all history), others prefer rebase (linear history), and some use `--ff-only` to reject non-fast-forward updates and prevent unexpected merge commits. The `pull.rebase` configuration setting controls default behavior.
参数
- --rebase=_true|merges|false_
- Rebase current branch on top of upstream after fetching instead of merging.
- --no-rebase
- Merge upstream into current branch (overrides `pull.rebase` config).
- --ff-only
- Only update if fast-forward is possible, fail otherwise.
- --no-ff
- Always create a merge commit, even when fast-forward is possible.
- --no-commit
- Perform the merge but stop before creating a commit.
- --squash
- Squash all fetched commits into a single commit on the current branch.
- --all
- Fetch from all remotes.
- --autostash
- Automatically stash and reapply uncommitted changes.
- --set-upstream
- Add upstream tracking reference for the pulled branch.
- --depth _n_
- Limit fetch to specified number of commits from remote tip.
- -t, --tags
- Fetch all tags from the remote.
- -q, --quiet
- Suppress output during fetch and merge.
- -v, --verbose
- Be verbose.
FAQ
What is the git-pull command used for?
git pull fetches from a remote and integrates the changes with the current branch. It is equivalent to running `git fetch` followed by `git merge`, or `git rebase` when the `--rebase` option is used. Pull strategies vary by workflow. Some teams prefer merge (preserving all history), others prefer rebase (linear history), and some use `--ff-only` to reject non-fast-forward updates and prevent unexpected merge commits. The `pull.rebase` configuration setting controls default behavior.
How do I run a basic git-pull example?
Run `git pull` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --rebase=_true|merges|false_ do in git-pull?
Rebase current branch on top of upstream after fetching instead of merging.