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
233 views
in Technique[技术] by (71.8m points)

git pull是针对当前分支还是所有分支?

假如本地又3个分支,对应的3个远程分支都不同步了
那么执行git pull
是将当前本地分支更新
还是所有分支都更新
如果所有分支都更新
如何只针对当前分支?


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

1 Reply

0 votes
by (71.8m points)

学会看文档 man git-pull

DESCRIPTION
       Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.
       
       More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge.

可以看到:

  1. 变更合并到当前分支
  2. 默认情况等价于 git fetch + git merge FETCH_HEAD(有默认自然有其他选项,这些要继续看文档)

其他分支会怎样?因为执行了 git fetch,其他分支的信息会拉取回来,但没有合并,所以会看到和远端的差异:

$ git checkout other-branch
Your branch is behind 'origin/other-branch' by 4 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

自己实践,看文档,可能比 SF 提题要快。


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

...