git push命令_Git Push命令解释
git push命令
The git push command allows you to send (or push) the commits from your local branch in your local Git repository to the remote repository.
git push命令允許您將提交(或推送 )從本地Git存儲庫中的本地分支發送到遠程存儲庫。
To be able to push to your remote repository, you must ensure that all your changes to the local repository are committed.
為了能夠推送到遠程存儲庫,必須確保已提交對本地存儲庫的所有更改 。
This command’s syntax is as follows:
該命令的語法如下:
git push <repo name> <branch name>There are a number of different options you can pass with the command, you can learn more about them in the Git documentation or run git push --help.
您可以通過命令傳遞許多不同的選項,可以在Git文檔中了解有關它們的更多信息,或運行git push --help 。
推送到特定的遠程存儲庫和分支 (Push to a Specific Remote Repository and Branch)
In order to push code, you must first clone a repository to your local machine.
為了推送代碼,必須首先將存儲庫克隆到本地計算機。
# Once a repo is cloned, you'll be working inside of the default branch (the default is `master`) git clone https://github.com/<git-user>/<repo-name> && cd <repo-name> # make changes and stage your files (repeat the `git add` command for each file, or use `git add .` to stage all) git add <filename> # now commit your code git commit -m "added some changes to my repo!" # push changes in `master` branch to github git push origin masterTo learn more about branches check out the links below:
要了解有關分支的更多信息,請查看以下鏈接:
git checkout
git結帳
git branch
git分支
推送到特定的遠程存儲庫及其中的所有分支 (Push to a Specific Remote Repository and All Branches in it)
If you want to push all your changes to the remote repository and all branches in it, you can use:
如果要將所有更改推送到遠程存儲庫及其中的所有分支,則可以使用:
git push --all <REMOTE-NAME>in which:
其中:
--all is the flag that signals that you want to push all branches to the remote repository
--all是標志,表示您希望將所有分支推送到遠程存儲庫
REMOTE-NAME is the name of the remote repository you want to push to
REMOTE-NAME是您要推送到的遠程存儲庫的名稱
推入具有力參數的特定分支 (Push to a specific branch with force parameter)
If you want to ignore the local changes made to Git repository at Github(Which most of developers do for a hot fix to development server) then you can use —force command to push by ignoring those changs.
如果您想忽略Github上對Git存儲庫所做的本地更改(大多數開發人員都在對開發服務器進行熱修復),則可以使用–force命令來忽略這些更改。
git push --force <REMOTE-NAME> <BRANCH-NAME>in which:
其中:
REMOTE-NAME is the name of the remote repository to which you want to push the changes to
REMOTE-NAME是要將更改推送到的遠程存儲庫的名稱
BRANCH-NAME is the name of the remote branch you want to push your changes to
BRANCH-NAME是您要將更改推送到的遠程分支的名稱
推忽略Git的預推鉤 (Push ignoring Git’s pre-push hook)
By default git push will trigger the --verify toggle. This means that git will execute any client-side pre-push script that may have been configured. If the pre-push scripts fails, so will the git push. (Pre-Push hooks are good for doing things like, checking if commit messages confirm to company standards, run unit tests etc…). Occasionally you may wish to ignore this default behavior e.g. in the scenario where you wish to push your changes to a feature branch for another contributor to pull, but your work-in-progress changes are breaking unit tests. To ignore the hook, simply input your push command and add the flag --no-verify
默認情況下, git push將觸發--verify切換。 這意味著git將執行可能已配置的任何客戶端預推腳本。 如果預推送腳本失敗,則git push也將失敗。 (Pre-Push掛鉤非常適合執行諸如檢查提交消息是否符合公司標準,運行單元測試等操作)。 有時,您可能希望忽略此默認行為,例如,在您希望將更改推送到功能分支以供其他貢獻者提取但正在進行的更改破壞了單元測試的情況下。 要忽略該鉤子,只需輸入您的push命令并添加標志--no-verify
git push --no-verify更多信息: (More Information:)
Git documentation - push
Git文檔-推送
Git hooks
吊鉤
翻譯自: https://www.freecodecamp.org/news/the-git-push-command-explained/
git push命令
總結
以上是生活随笔為你收集整理的git push命令_Git Push命令解释的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 做梦梦到被辞职了是什么意思
- 下一篇: 梦到弟弟妹妹死了是什么征兆