红穆笔记

git push

推送提交到遠程倉庫

100% 瀏覽器本地處理 0 數據上傳

常用示例

將當前分支的本地更改推送到其默認的遠程對應分支

git push

將指定本地分支的更改推送到其遠程對應分支

git push {{遠程倉庫名}} {{本地分支名}}

將指定本地分支的更改推送到其遠程對應分支,並將該遠程分支設爲該本地分支 push/pull 的默認目標分支

git push {{[-u|--set-upstream]}} {{遠程倉庫名}} {{本地分支名}}

將指定本地分支的更改推送到指定的遠程分支

git push {{遠程倉庫名}} {{本地分支名}}:{{遠程分支名}}

將所有本地分支的更改推送到指定遠程倉庫中各個對應分支

git push --all {{遠程倉庫名}}

刪除遠程倉庫中的分支

git push {{遠程倉庫名}} {{[-d|--delete]}} {{遠程分支名}}

刪除沒有本地對應分支的遠程分支

git push --prune {{遠程倉庫名}}

推送本地的新標籤到遠程倉庫

git push --tags

提示:花括號{{…}}是需要替換的參數(路徑、文件名等);命令只在本機終端執行,本站不保存任何輸入。

英文原文對照

展開英文說明與示例(來源 tldr-pages)

Push commits to a remote repository. More information

Send local changes in the current branch to its default remote counterpart

git push

Send changes from a specific local branch to its remote counterpart

git push {{remote_name}} {{local_branch}}

Send changes from a specific local branch to its remote counterpart, and set the remote one as the default push/pull target of the local one

git push {{[-u|--set-upstream]}} {{remote_name}} {{local_branch}}

Send changes from a specific local branch to a specific remote branch

git push {{remote_name}} {{local_branch}}:{{remote_branch}}

Send changes on all local branches to their counterparts in a given remote repository

git push --all {{remote_name}}

Delete a branch in a remote repository

git push {{remote_name}} {{[-d|--delete]}} {{remote_branch}}

Remove remote branches that don't have a local counterpart

git push --prune {{remote_name}}

Publish tags that aren't yet in the remote repository

git push --tags

命令信息

命令名git push
用途推送提交到遠程倉庫
適用平臺通用
示例數量8 條
官方文檔https://git-scm.com/docs/git-push
數據來源tldr-pages(CC-BY-4.0)· 社區中文翻譯

常見問題

git push 命令是做什麼的?

推送提交到遠程倉庫

git push 怎麼用?

頁面按場景列出了8 條常用示例:每條示例先說明用途,再給出可直接複製的完整命令(花括號裏是需要替換的參數)。

git push 最常用的操作是什麼?

將當前分支的本地更改推送到其默認的遠程對應分支:git push

命令裏的花括號是什麼意思?

花括號{{…}}表示需要替換成你自己的值,例如路徑、文件名;同名參數方括號(如 [-C|--directory])表示可選寫法。