当前回答
简单解释:
git fetch
获取元数据。 如果您想要检查最近创建的分支, 您可能需要在退出前进行获取 。
git pull
从远程获取元元数据,并将文件从远程移动并合并到分支
其他回答
我也为此挣扎过。事实上,我来到这里时,用谷歌搜索了完全相同的问题。阅读了所有这些答案,终于在我脑海中画出了一张图片,我决定试着从下面看2个储存库和1个沙箱的状况,以及一段时间以来在看它们的版本时所采取的行动。这就是我所想出来的。如果我在任何地方搞砸了,请纠正我。
三个邮箱有一个接听器:
--------------------- ----------------------- -----------------------
- Remote Repo - - Remote Repo - - Remote Repo -
- - - gets pushed - - -
- @ R01 - - @ R02 - - @ R02 -
--------------------- ----------------------- -----------------------
--------------------- ----------------------- -----------------------
- Local Repo - - Local Repo - - Local Repo -
- pull - - - - fetch -
- @ R01 - - @ R01 - - @ R02 -
--------------------- ----------------------- -----------------------
--------------------- ----------------------- -----------------------
- Local Sandbox - - Local Sandbox - - Local Sandbox -
- Checkout - - new work done - - -
- @ R01 - - @ R01+ - - @R01+ -
--------------------- ----------------------- -----------------------
三号邮局拉一拉一拉
--------------------- ----------------------- -----------------------
- Remote Repo - - Remote Repo - - Remote Repo -
- - - gets pushed - - -
- @ R01 - - @ R02 - - @ R02 -
--------------------- ----------------------- -----------------------
--------------------- ----------------------- -----------------------
- Local Repo - - Local Repo - - Local Repo -
- pull - - - - pull -
- @ R01 - - @ R01 - - @ R02 -
--------------------- ----------------------- -----------------------
--------------------- ----------------------- -----------------------
- Local Sandbox - - Local Sandbox - - Local Sandbox -
- Checkout - - new work done - - merged with R02 -
- @ R01 - - @ R01+ - - @R02+ -
--------------------- ----------------------- -----------------------
这帮助我理解了为什么买东西很重要。
git fetch
将检索远程分支,以便您能够git diff
或git merge
它们与当前分支一起存在。git pull
将运行当前分支所跟踪的远程条格获取,然后合并结果。您可以使用git fetch
查看是否对远程分支有任何更新,而不必将其与您的本地分支合并。
我想用视觉来描述这些事情。也许其他开发商也想看,所以我还要补充一下。我不完全确定这一切是否都正确,所以如果你发现任何错误,请评论。
LOCAL SYSTEM
. =====================================================
================= . ================= =================== =============
REMOTE REPOSITORY . REMOTE REPOSITORY LOCAL REPOSITORY WORKING COPY
(ORIGIN) . (CACHED)
for example, . mirror of the
a github repo. . remote repo
Can also be .
multiple repo's .
.
.
FETCH *------------------>*
Your local cache of the remote is updated with the origin (or multiple
external sources, that is git's distributed nature)
.
PULL *-------------------------------------------------------->*
changes are merged directly into your local copy. when conflicts occur,
you are asked for decisions.
.
COMMIT . *<---------------*
When coming from, for example, subversion, you might think that a commit
will update the origin. In git, a commit is only done to your local repo.
.
PUSH *<---------------------------------------*
Synchronizes your changes back into the origin.
拥有远程镜像的一些主要优点是:
- 业绩 业绩业绩 业绩业绩(在不试图通过网络挤压所有承诺和信息的情况下标注所有承诺和信息)
- 反馈反馈反馈反馈反馈有关您所在的本地回收站的状况( 例如, 我使用阿特拉斯斯的源树树, 这将给我一个灯泡, 显示我是否承诺提前或落后于来源 。 这个信息可以用 GIT Fitch 来更新 ) 。
Git 获取
帮助您从一个git repository
。让我们假设你在一个团队中工作 使用GitFlow
,其中团队在多个branches
(特征). 与git fetch --all
command
您可以了解所有新的信息branches
内repository
.
大部分git fetch
用于git reset
。例如,您想要将全部本地更改恢复到当前仓库状态。
git fetch --all // get known about latest updates
git reset --hard origin/[branch] // revert to current branch state
Git 拉着
此命令更新您branch
与当前repository
branch
状态。让我们继续GitFlow
多个特性branches
原为merged
至develop
分支,当您想要为项目开发新特性时,您必须去开发branch
并做一个git pull
以获得当前状态develop
branch
GitFlow 文档文档https://gist.github.com/peterdeweese/4251497
推荐文章
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?
- HEAD和master的区别
- GIT克隆在windows中跨本地文件系统回购
- RPC失败;卷度传输已关闭,剩余未完成的读取数据
- 我应该在.gitignore文件中添加Django迁移文件吗?
- 错误:您对以下文件的本地更改将被签出覆盖
- Git rebase—即使所有合并冲突都已解决,仍然会继续报错
- 在Git中,我如何知道我的当前版本是什么?
- 跟踪所有远程git分支作为本地分支
- 为什么要把Gradle Wrapper提交给VCS?
- 自定义SSH端口上的Git
- git如何显示不存在于.gitignore中的未跟踪文件
- Git错误:遇到7个文件应该是指针,但不是
- GitHub克隆与OAuth访问令牌