git push和git pull有什么区别? [英] What is the difference between git push and git pull?

查看:1082
本文介绍了git push和git pull有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚偶然发现了一些特别的东西。我在夏季的工作中问了一位同事,帮助我为我的代码建立了一个新的远程git仓库,并且对他做了什么以及我想做什么感到困惑。我要求他发送他的配置文件,以便能够看到他的遥控器的路径,并发现他没有遥控器。当我问他这个问题时,他解释了他的工作流程:


  1. 本地修改某些内容


  2. 移至远程目录

  3. git pull c:\localdir

因此,他不是推着遥控器,而是不断地从他的本地存储库中取回到我们的服务器上。向后工作的种类。当我向他询问这件事时,他问我有什么不同,我不能真正回答他,但我认为有些事情是正确的?所以我的问题对你来说,所有的东西都是:推送到远程并从远端拉出来的区别是什么?

解决方案

到一个远程:发送一些提交你有另一个git回购。 git repo被认为是远程,但它可以是硬盘驱动器上另一个文件夹中的repo。
从远程获取:从远程回购获得一些提交并将它们合并到当前的HEAD中(您当前正在检出您的回购)

您的同事可能拥有使用pull而不是push是因为你的存储库可能没有可用(没有运行git守护进程或gitweb或ssh服务器),但是他的计算机可用。因为它是一个服务器,他可能不想公开一个可能成为攻击向量的git守护进程/服务。



但是,如果您的存储库是共享/可用的,他只能做到:


  1. 在本地修改某些内容

  2. 提交

  3. 推送至您的存储库


I just stumbled over something peculiar today. I asked a co-worker at my summer job to help me set up a new remote git repo for my code and there was a lot of confusion about what he did and what I wanted to do. I asked him to send over his config to be able to see the path to his remote and found out that he didn't have a remote. When I asked him about this he explained his workflow like this:

  1. Change something locally
  2. Commit
  3. Move to remote dir
  4. git pull c:\localdir

So instead of pushing to a remote he constantly pulled from his local repo to the one on our server. Sort of working backwards. When I confronted him about this he asked me what the difference was and I could not really answer him, but I think there are something right?

So my question to you all is: What is the difference in pushing to a remote and pulling from a remote?

解决方案

Pushing to a remote : send some commits you have to a another git repo. The git repo is considered as "remote", but it can be a repo in another folder of your hard drive. pulling from a remote : get some commits from a remote repo and merge them in your current HEAD (your current checkout of your repo)

Your coworker might have use pull instead of push because your repository might not have been available (no git daemon running, or gitweb, or ssh server on), but his was avalaible from your computer. As it is a server, he might not want to expose a git daemon/service which could be a vector of attack.

But if your repository was shared/available, he would just have been able to do :

  1. change something locally
  2. commit
  3. push to your repository

这篇关于git push和git pull有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆