简体   繁体   English

git fetch不会更新.git / refs / remotes / origin / master

[英]git fetch does not update .git/refs/remotes/origin/master

I have a local git repository cloned from a central server. 我有一个从中央服务器克隆的本地git存储库。 The last commit of my local master branch is commit 1 . 我的本地master分支的最后一个提交是commit 1

The central repository has a new commit 2 in master branch. 中央存储库在master分支中有一个新的commit 2

I ran git fetch origin master to update my local refs, I found refs/remotes/origin/master does not update. 我运行git fetch origin master更新了我的本地引用,我发现refs/remotes/origin/master没有更新。

And then I checked .git/FETCH_HEAD . 然后我检查了.git/FETCH_HEAD This is, however, already commit 2 但是,这已经提交了2

My local config for the fetch: 我的本地配置:

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = #########

Also I am able to login to central and check the bare repository there. 另外,我能够登录到Central并检查那里的裸仓库。 project.git/refs/heads/master is commit 2 project.git/refs/heads/master提交2

Then I tried to run git pull origin master . 然后我尝试运行git pull origin master Surprisingly, commit 2 is merged into my local repository. 令人惊讶的是, 提交2被合并到我的本地存储库中。

And git diff origin/master even shows me the diffs between commit 1 and commit 2 . git diff origin/master甚至向我展示了commit 1commit 2之间的差异。 But origin and my local repository have the same contents at this point. 但是,此时Origin和我的本地存储库具有相同的内容。

My questions are: 我的问题是:

  1. Why git fetch does not download the latest update from origin? 为什么git fetch不从源下载最新的更新?
  2. Why git pull still works in this case? 为什么git pull在这种情况下仍然有效?
  3. Is it a problem of my local config or the central config? 这是我的本地配置还是中央配置的问题?

If you run 如果你跑

git fetch origin

then refs/remotes/origin/master will be updated. 那么refs/remotes/origin/master将被更新。

If you specify a single ref to git fetch origin, then it assumes you just want to pull that to FETCH_HEAD 如果您为git fetch origin指定一个引用,则假定您只想将其拉到FETCH_HEAD

you can run 你可以跑

git fetch origin master:refs/remotes/origin/master

and that will also update 这也将更新

When you run git fetch origin master —or, if you use git pull , it can do this for you—that should update your origin/master . 当您运行git fetch origin master或者,如果您使用git pull ,它可以为您做到这一点), 则应更新您的origin/master

This kind of updating, however, was first put into Git in version 1.8.4 (released August 2013). 但是,这种更新最初是在1.8.4版(2013年8月发布)中引入Git的。 Some extremely out of date distributions still use Git version 1.7.x. 一些非常过时的发行版仍使用Git 1.7.x版本。 If you have such an ancient Git, git fetch origin master will fail to update origin/master . 如果您拥有如此古老的Git,则git fetch origin master将无法更新origin/master

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git refs / remotes / origin / master不指向有效对象 - Git refs/remotes/origin/master does not point to a valid object 为什么git fetch origin + refs / heads / master:refs / remotes / origin / mymaster和git fetch origin master:mymaster的行为不同? - Why behaviour of git fetch origin +refs/heads/master:refs/remotes/origin/mymaster and git fetch origin master:mymaster is different? Git 中的“refs/heads/master”是否与“refs/remotes/origin/master”相同? - Is "refs/heads/master" same as "refs/remotes/origin/master" in Git? 自制安装错误期间失败:git fetch origin master:refs/remotes/origin/master --tags --force - homebrew install error Failed during: git fetch origin master:refs/remotes/origin/master --tags --force 自制软件安装:失败期间:git 获取原始主机:refs/remotes/origin/master -n --depth=1 - Homebrew install: Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1 Git:内部错误:refs / remotes / origin / master不是有效的打包引用 - Git: Internal error: refs/remotes/origin/master is not a valid packed reference 致命:refspec的远程部分不是.git / refs / heads / master中的有效名称:.git / refs / remotes / origin / master - fatal: remote part of refspec is not a valid name in .git/refs/heads/master:.git/refs/remotes/origin/master git fetch失败“refs / remotes / origin / pr / 34跟踪两者” - git fetch failed “refs/remotes/origin/pr/34 tracks both” 遥控器的“ git fetch”遥控器 - “git fetch” remote refs of remotes Git:“警告:忽略损坏的 ref refs/remotes/origin/master 错误修订版‘refs/remotes/origin/master..HEAD’ - Git: "warning: ignoring broken ref refs/remotes/origin/master bad revision 'refs/remotes/origin/master..HEAD'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM