Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

git - 'git pull'和'git fetch'有什么区别?(What is the difference between 'git pull' and 'git fetch'?)

Moderator Note: Given that this question has already had sixty-seven answers posted to it (some of them deleted), consider whether or not you are contributing anything new before posting another one.

(主持人注意:鉴于此问题已经发布了67个答案 (其中一些已删除),请在发布另一个问题之前考虑您是否正在贡献新内容 。)

What are the differences between git pull and git fetch ?

(git pullgit fetch什么区别?)

  ask by pupeno translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In the simplest terms, git pull does a git fetch followed by a git merge .

(用最简单的术语来说, git pull进行git fetch然后进行git merge 。)

You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/ .

(您可以随时执行git fetch来更新refs/remotes/<remote>/下的远程跟踪分支。)

This operation never changes any of your own local branches under refs/heads , and is safe to do without changing your working copy.

(此操作绝不会更改refs/heads下您自己的任何本地分支,并且可以安全地执行而不更改您的工作副本。)

I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn't recommend doing this).

(我什至听说有人在后台执行cron作业中定期运行git fetch (尽管我不建议这样做)。)

A git pull is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

(git pull是您要执行的操作,以使本地分支的远程版本保持最新,同时还更新其他远程跟踪分支。)

Git documentation – git pull :

(Git文档– git pull :)

In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD .

(在默认模式下, git pullgit fetch简写,其次是git merge FETCH_HEAD 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...