← 返回命令列表

Linux command

git-push 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Push to remote

git push [origin] [branch]

Push and set upstream

git push -u [origin] [branch]

Push all branches

git push --all

Push tags

git push --tags

Force push safely

git push --force-with-lease

Delete a remote branch

git push [origin] --delete [branch]

说明

git push uploads local commits to a remote repository, updating remote refs with local refs and transferring the objects needed to complete them. This is how local work becomes shared with collaborators. The `--force-with-lease` option provides a safer alternative to `--force` by checking that the remote hasn't been updated since your last fetch before overwriting. The `-u` flag sets upstream tracking, simplifying future push and pull commands.

参数

-u, --set-upstream
Set upstream tracking reference for the branch.
--all
Push all branches.
--tags
Push all refs under refs/tags.
--force
Force update remote refs, even if not a fast-forward.
--force-with-lease
Force push only if the remote ref matches what was last fetched.
--force-if-includes
Refuse to force-update if remote-tracking ref has updates not integrated locally.
--delete
Delete the specified remote refs.
--dry-run
Do everything except actually send the updates.
--no-verify
Skip pre-push hooks.
-q, --quiet
Suppress all output, including the listing of updated refs.
-v, --verbose
Run verbosely.
--progress
Force progress status output even if stderr is not a terminal.
--prune
Remove remote branches that do not have a local counterpart.
-o _option_, --push-option _option_
Transmit string to server-side receive hooks.
--porcelain
Produce machine-readable output.

FAQ

What is the git-push command used for?

git push uploads local commits to a remote repository, updating remote refs with local refs and transferring the objects needed to complete them. This is how local work becomes shared with collaborators. The `--force-with-lease` option provides a safer alternative to `--force` by checking that the remote hasn't been updated since your last fetch before overwriting. The `-u` flag sets upstream tracking, simplifying future push and pull commands.

How do I run a basic git-push example?

Run `git push [origin] [branch]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -u, --set-upstream do in git-push?

Set upstream tracking reference for the branch.