博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git push命令_Git Push命令解释
阅读量:2520 次
发布时间:2019-05-11

本文共 3363 字,大约阅读时间需要 11 分钟。

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 

There are a number of different options you can pass with the command, you can learn more about them in the or run git push --help.

您可以通过命令传递许多不同的选项,可以在了解有关它们的更多信息,或运行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/
/
&& cd
# make changes and stage your files (repeat the `git add` command for each file, or use `git add .` to stage all)git add
# now commit your codegit commit -m "added some changes to my repo!"# push changes in `master` branch to githubgit push origin master

To learn more about branches check out the links below:

要了解有关分支的更多信息,请查看以下链接:

推送到特定的远程存储库及其中的所有分支 (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 

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 

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 push命令

转载地址:http://dqrwd.baihongyu.com/

你可能感兴趣的文章
css3最新技术教程
查看>>
【tool】测试驱动开发全攻略
查看>>
VIM命令图---可定制版
查看>>
《坐热板凳》第八次团队作业:Alpha冲刺(第三天)
查看>>
关于wxWidgets
查看>>
codevs 1160 蛇形矩阵
查看>>
在outlook中查找Skype的聊天记录
查看>>
netsh命令
查看>>
Polymorphism (C# Programming Guide)
查看>>
Gi命令行操作
查看>>
spring boot 中使用 jpa以及jpa介绍
查看>>
yum_rpm(利用dvd建立本地yum库)
查看>>
寻找关键帧
查看>>
今日笑话
查看>>
20180603_navicat 连接sqlserver提示要安装 sql server native client
查看>>
nginx set变量后lua无法改值
查看>>
baseAdapter
查看>>
别让你妈知道!
查看>>
JAVA设计模式之迭代子模式
查看>>
Java程序生成exe可执行文件
查看>>