单击阶段更改后,我可以选择提交或推送。推的用途是什么?它要求我选择目标存储库和源分支。在我这样做之后。这个推送命令会改变对方的仓库吗?
3 回答
Pushing is how you transfer commits from your local repository to a remote repository (typically the origin). The most common use case for git push is to publish your local changes to a central repository. After you’ve accumulated several local commits and are ready to share them with other users.
Take a look at the image below for a self explanatory schema :
As you can see in the picture with a push command you can transfer object from your local repository to a remote repository. The counterpart of a git push is git fetch (or pull that automatically merge) command, that as you can see transfer changes from remote repository to your local repository.
Below you can see what happens when your local master has progressed past the central repository’s master and you publish changes by running git push origin master
:
Synthax
git push [alias] [branch]
Tags aren't automatically pushed when you push a branch, so to push them you have to use the following synthax :
git push <remote> --tags
In the typical case, push transfers your changes from a cloned repository which you committed to, to the original repository which was cloned
For the general case, see the useful comments to the answer. I am not sure whether the remotes have to be in some way related to the repository you cloned, and if not, how can changes be merged into an arbitrary repository. But I doubt if that's what you are looking to understand, so the typical case should be sufficient.
Push 命令确实会将您的提交发送到您配置的远程存储库。如果您没有任何远程存储库,则 push 命令将失败。
这主要用于远程存储库可以接收来自许多来源的提交并保持最新。在开发人员团队中,从远程存储库中提取提交是很正常的,因此您的本地项目与生产环境保持同步,当您完成任务时,您推送它们以更新远程存储库。