Git pull and fetch are two commands that are regularly used by Git users. Let’s see the difference between both commands.

Git pullfetch是Git用户经常使用的两个命令。 让我们看看两个命令之间的区别。

For the sake of context, it’s worth remembering that we’re probably working in a clone repo. What’s a clone? It's simply a duplicate of another repository. It is basically getting your own copy of someone else’s source code.

出于上下文考虑,值得记住的是,我们可能正在克隆克隆中。 什么是克隆? 它只是另一个存储库的副本。 它基本上是在获取您自己的他人源代码副本。

That said, to keep your clone updated with whatever changes may have been applied to the original, you’ll need to bring those to your clone.

就是说,要使克隆更新时可以对原始副本进行任何更改,则需要将其带入克隆。

That’s where fetch and pull come in.

那就是fetchpull入的地方。

git fetch is the command that tells your local git to retrieve the latest meta-data info from the original (yet doesn’t do any file transferring. It’s more like just checking to see if there are any changes available).

git fetch是告诉您的本地git从原始数据库中检索最新元数据信息的命令(但尚未进行任何文件传输。它更像是检查是否有可用更改)。

git pull on the other hand does that AND brings (copy) those changes from the remote repository.

另一方面, git pull做到并从远程存储库中带来(复制)那些更改。

For example:

例如:

git pull origin ankur bugfix

The takeaway is to keep in mind that there generally are at least three copies of a project on your workstation.

要记住的一点是,您的工作站上通常至少有一个项目的三个副本。

  • One copy is your own repository with your own commit history (the already saved one, so to say). 一个副本是您自己的存储库,具有自己的提交历史记录(可以说已经保存了一个)。
  • The second copy is your working copy where you are editing and building (not committed yet to your repo). 第二个副本是您正在编辑和构建的工作副本(尚未提交到您的存储库)。
  • The third copy is your local “cached” copy of a remote repository (probably the original from where you cloned yours). 第三个副本是远程存储库的本地“缓存”副本(可能是您从中克隆副本的原始副本)。

You can use git fetch to know the changes done in the remote repo/branch since your last pull. This is useful to allow for checking before doing an actual pull, which could change files in your current branch and working copy (and potentially lose your changes, etc).

您可以使用git fetch知道自上次提取以来在远程存储库/分支中所做的更改。 这有助于在进行实际提取之前进行检查,这可能会更改当前分支和工作副本中的文件(并可能丢失所做的更改等)。

git fetch
git diff ...origin

翻译自: https://www.freecodecamp.org/news/git-fetch-vs-pull/

Git Fetch vs Pull:Git Fetch和Git Pull命令之间有什么区别?相关推荐

  1. #39;git pull#39;和#39;git fetch#39;有什么区别?

    主持人注意:鉴于此问题已经发布了67个答案 (其中一些已删除),请在发布另一个问题之前考虑您是否正在贡献新内容 . git pull和git fetch什么区别? #1楼 我花了一点时间来了解有什么区 ...

  2. 理解Git的设计思想,详解git文件夹,以及详解add、commit、push,fetch、pull、merge指令

    在项目目录执行git init,此目录将纳入git管理,git将会自动生成.git文件夹,用以记录git配置(.git/config)和版本信息(commit-id)和文件集合.下面是.git文件夹的 ...

  3. git 拉取和获取 pull 和 fetch 区别

    使用Git  直接提交的话   直接 push 获取最新版本  有两种  拉取 和 获取 pull 和 fetch git  pull     从远程拉取最新版本 到本地  自动合并 merge   ...

  4. Git 远程操作 —— clone、push、pull、fetch

    1. git 的远程操作 远程操作,与本地(local)操作相对,主要有以下的 5 个 git 命令: git clone, git remove git fetch git pull, git pu ...

  5. git pull origin master与git pull --rebase origin master的区别

    建议:最好看一遍廖雪峰的git教程,看完时间差不多就两个小时,git相关的知识写的很清楚,看完整个人都豁然开朗,很多git的问题都想通了. 区别: git pull=git fetch + git m ...

  6. 本地没有任何修改,只是git pull时,显示git ahead of ‘origin/master‘ by * commits

    目录 TL;DR 问题 原因 解决方案 TL;DR 本地没有更改,只是从远程pull,但是显示Your branch is ahead of 'origin/master' by 3 commits. ...

  7. git pull远程master_github与Git实用操作图解之一

    1. git和github工具的联系 2. github创建Git 仓库 New repository -> repository name(仓库名称) ->Public(免费) -> ...

  8. git 的批量克隆 批量切换分支 批量pull

    批量克隆 将cloneList.txt和git_clone_batch.bat两个文件,放到用于存放项目的根目录. 在cloneList.txt文件中维护需要批量克隆的http地址,每行一个项目地址. ...

  9. git修改代码后,如何再git pull而不覆盖修改的代码

    一. git pull不覆盖修改的代码: 先把修改好的代码存放在缓存里,等代码拉下来以后再恢复缓存里的修改的代码 步骤: 1.git stash save "这里是注释" 2.gi ...

最新文章

  1. “Python之父”从Dropbox退休
  2. Windows Phone开发(20):当MediaElement和VideoBrush合作的时候
  3. 纸板箱机器人制作比例图纸_造一个黄油机器人(Butter Robot)
  4. 从0开始搭建ELK及采集日志的简单应用
  5. 纠错——【Singleton array array(0.2) cannot be considered a valid collection.】
  6. 跟我一起学.NetCore之选项(Options)核心类型简介
  7. c# oracle datasource,C# 连接Oracle 数据库 示例源码下载
  8. element label动态赋值_基于Element封装可拖动放大缩小的弹窗
  9. java for 面试题_Java面试题整理
  10. UpdateData()函数使用
  11. 一、CC2530简介
  12. C++ 结构体内存对齐
  13. node.js入门教程(B站黑马程序员)
  14. 触动精灵游戏脚本制作
  15. 给程序员推荐的一款机械键盘
  16. python控制EnergyPlus方法(linux)
  17. 欢迎页面welcome.jsp
  18. 超详细:R语言缺失值及异常值处理
  19. P1253 [yLOI2018] 扶苏的问题 (线段树)
  20. 在PHP中如何使用Predis

热门文章

  1. IDEA配置GitHub和Gitee
  2. H5 自动播放背景音频,兼容安卓和苹果手机, ios createInnerAudioContext 无法自动播放解决
  3. 微信小程序动画无限循环 掉花
  4. 3 OC 属性和方法
  5. Linux Test Project 测试套件说明
  6. Qt 程序在 Windows 下的发布
  7. projecteuler_problem10
  8. Linux编程之自定义消息队列
  9. ORACLE初次安装自动安装软件包
  10. ACM-ICPC历届世界总冠军名单1977-2015