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 master

To 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命令解释相关推荐

  1. git status清空_Git常见命令和遇到问题的解决办法

    一.Git整体理解 Git代码管理是分布式管理方式系统,优点在于其极高的安全性和非常强大的分支管理. image.png 工作区(working directory): 就是本地的代码区,电脑能看到的 ...

  2. git 常用命令_git常用命令的使用

    1.$ touch README.md 新建一个文件夹,在文件夹下右键bash出现命令行,输入这行命令创建一个readme文件2.$ git init 把当前文件夹变成一个git仓库3.$ git a ...

  3. 常用命令_GIT常用命令大全

    Git 是一个很强大的分布式版本控制系统.它不但适用于管理大型开源软件的源代码,管理私人的文档和源代码也有很多优势. 克隆远程文件: git clone https://gitee.com/abcd/ ...

  4. Git系列:git push -u origin master命令理解

    Git系列:git push -u origin master命令理解 git push -u origin master git push -u origin master 相当于 git bran ...

  5. git常用命令之Push

    9. Push 1.将本地当前分支 推送到 远程指定分支上(注意:pull是远程在前本地在后,push相反): git push origin <本地分支名>:<远程分支名> ...

  6. git 配置组合指令_Git命令行基本操作

    原标题:Git命令行基本操作 先来看看图的介绍吧 0. 安装Git 网上有很多Git安装教程,如果需要图形界面,windows下建议使用TortoiseGit,linux建议使用Git GUI或者GI ...

  7. eslint git提交不上_Git常用命令及日常问题集锦

    作者 | 五月君,全栈工程师,慕课网认证作者 来源 | 慕课网(imooc.com) Git是当下最流行的版本管理工具,结合自己工作中的实际应用做了以下梳理. 基础命令 git init 初始化本地仓 ...

  8. git linux 登陆_Git安装及基础命令

    前言 Git是现在很流行的一种分布式版本控制系统,在处理冲突方面更容易,可以在各自的分支上进行开发,开发一个阶段再合并到一起.Git没网的是后也可以提交,等到有网了再push到远端仓库.还可以根据团队 ...

  9. git 命令commit_Git Commit命令解释

    git 命令commit The git commit command will save all staged changes, along with a brief description fro ...

最新文章

  1. 使用scipy进行聚类
  2. postgresql----文本搜索类型和检索函数
  3. AgilePoint商业流程管理平台
  4. 数据库高级知识——mysql架构介绍(一)
  5. ZooKeeper学习第四期---构建ZooKeeper应用
  6. spring 3.0.5+velocity tools 2.0
  7. 为什么你从来没做过发起人?
  8. hashmap的负载因子为什么是0.75而不是其他值或者1
  9. PHOTOSHOP教程
  10. android交友php,android交友约会社交APP完整源码Dating App 3.7(服务端+客户端)
  11. 方舟生存 服务器修改器,【修改贴】关于单机版gg修改器的应用。
  12. 安卓计步器是如何实现计步的
  13. ueditor imageup.php,ThinkPHP整合百度Ueditor,thinkphpueditor_PHP教程
  14. 【Python基础】from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import] Mod
  15. Java多线程--概述-转自林炳文Evankaka
  16. 手把手接入高德地图API——POI周边搜索功能实现
  17. c++ Lake Counting
  18. php网页播放器源码免费,基于Flowplayer打造一款免费的WEB视频播放器附源码
  19. 深度学习代码学习笔记(一)——阶跃函数与激活函数的python代码实现
  20. 初学linux(-)

热门文章

  1. String | 344. Reverse String
  2. zookeeper的四种类型的节点
  3. bzoj 4552: [Tjoi2016Heoi2016]排序
  4. Android商城开发系列(二)——App启动欢迎页面制作
  5. bzoj3503: [Cqoi2014]和谐矩阵
  6. 使用flot.js 发现x轴y轴无法显示轴名称
  7. PHP实现单击“添加”按钮增加一行表单项,并将所有内容插入到数据库中
  8. codeforces 483B Friends and Presents 解题报告
  9. XP下修改IIS连接数
  10. Mule,目前综合状态最良好的开源ESB方案引文