在我将要讲解的Git教程中,Git提交用于存储您所做的更改。
git push是用来做什么的?
在我将要讲解的Git教程中,Git提交用于存储您所做的更改。
git push是用来做什么的?
当前回答
只想补充以下几点:
在你提交之前你不能推送,因为我们使用git push来将你本地分支上的提交推送到远程存储库。
git push命令有两个参数:
远程名称,例如origin 分支名称,例如master
例如:
git push <REMOTENAME> <BRANCHNAME>
git push origin master
其他回答
提交:快照|变更集|版本|历史记录|存储库“另存为”。Git仓库=一系列的提交(树)。
本地存储库:计算机上的存储库。
远程存储库:服务器上的存储库(GitHub)。
git commit:追加一个新的提交(最后一次提交+阶段性修改)到本地存储库。(提交文件存储在/.git文件夹中。)
git push, git pull:同步本地存储库和其关联的远程存储库。推—从本地应用更改到远程,拉—从远程应用更改到本地。
Git push用于将您在本地存储库上完成的提交添加到远程存储库中。与git一起,它允许人们进行协作。
一个非常粗略的类比:如果我们比较git commit是保存一个编辑过的文件,那么git push是将该文件复制到另一个位置。
请不要把这个类比放在这个上下文之外——提交和推送不太像保存编辑过的文件并复制它。也就是说,为了比较起见,它应该成立。
提交:向本地存储库添加更改
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.