Git分支在我切换到主分支时与原始状态相同。

huangapple go评论65阅读模式
英文:

Git branch is at the same state as origin when I checkout to master

问题

After working on a feature branch and also successfully setting my PR, I usually switch back to master. git checkout master gives me when checking out: Switched to branch "master". Your branch is at the same level as 'origin/master'.

Then when I do a git pull, git pulls down all the new changes on master and merges them into my local master.

Step 1: git checkout master
Step 2: git pull

But why does it tell me at step 1 that it is up to date with the origin? But in step 2, it fetches and merges the new changes. According to my understanding, it would be not up to date then!

英文:

After working on a feature branch and also successfully setting my PR, I usually switch back to master. git checkout master gives me when checking out: Switched to branch "master". Your branch is at the same level as 'origin/master'.

Then when I do a git pull, git pulls down all the new changes on master and merges them into my local master.

Step 1: git checkout master
Step 2: git pull

But why does well tell me at step 1. that it is up to date with the origin? But in step 2 it fetches and merges the new changes. According to my understanding, it would be yes then not up to date!?

答案1

得分: 2

当你执行 git checkout master 时,Git 不会自动发起网络请求来检查远程服务器的状态。它仅仅检查本地可用的缓存和历史记录树。

然而,如果你在特性分支上执行 git pull --all,并且远程有变更被推送,那么只有在你执行 git checkout master 时,Git 才会报告你的本地 master 分支落后于 origin/master

英文:

When you git checkout master git will not automatically make a network request to check the remote server state. It merely checks the caches and the history tree available locally to you.

However, if you happen to git pull --all while in the feature branch and there were changes pushed to the remote, only then git will report that your local master branch is behind origin/master when you git checkout master .

huangapple
  • 本文由 发表于 2023年6月12日 16:44:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76454927.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定