在我将要讲解的Git教程中,Git提交用于存储您所做的更改。
git push是用来做什么的?
在我将要讲解的Git教程中,Git提交用于存储您所做的更改。
git push是用来做什么的?
当前回答
Git提交是提交在本地存储库中暂存的文件。Git push是快进合并本地的主分支和远程的主分支。但合并并不总能成功。如果出现拒绝,您必须拉,以便您可以成功地进行git推送。
其他回答
Git push用于将您在本地存储库上完成的提交添加到远程存储库中。与git一起,它允许人们进行协作。
基本上,Git commit会把你的更改放到本地存储库中,而Git push会把你的更改发送到远程位置。
有三件事需要注意:
Working directory — folder where our code files are present Local repository — This is inside our system. When we do the commit command the first time, then this local repository is created in the same place where our working directory is. Checkit (.git) file get created. After that whenever we do commit, this will store the changes we make in the file of the working directory to the local repository (.git). Remote repository — This is situated outside our system like on servers located any where in the world, like GitHub. When we make a push command then code from our local repository gets stored at this remote repository.
Git提交只是正式保存我们的更改。对于每次提交,我们都会给出commit消息 一旦我们完成了提交,我们可以将它推到远程,以全局查看我们的更改。
这意味着我们可以在推送到远程之前进行多次提交(我们可以看到发生的提交列表和消息)。 Git用提交id保存每次提交,这是一个40位的代码。
只有当我想在远程查看我的更改时,我才使用Git push(之后我会检查我的代码是否在Jenkins中工作)。
基本上,git提交“将更改记录到存储库”,而git推送“更新远程引用和相关对象”。因此,第一个用于连接本地存储库,而后一个用于与远程存储库交互。
下面是Oliver Steele的一张漂亮的图片,解释了Git模型和命令:
阅读更多关于git push和git pull的内容:push和pull(我首先提到的文章)。