简体   繁体   中英

Git couldn't find remote ref for a tag or commit hash

I am trying to pull (I also get the same problem with fetch) to a specific tag on a remote branch. I am trying to run:

 git pull origin v0.0.2.1

Where v0.0.2.1 is the name of my tag. I get this error message:

fatal: Couldn't find remote ref v0.0.2.1
fatal: The remote end hung up unexpectedly

I get the same error message if I replace "v0.0.2.1" with the hash for that tag or the hash for the commit the tag refers to.

I have checked that the remote does actually have this tag and this commit (in fact I can successfully run the above commands on a different machine that has this repository). I checked that the .git/config files are the same on both of these machines.

The following still works:

 git pull origin HEAD

Also, I used

git ls-remote origin

And I get the following (among other things):

016d51475640e738b24cce2fb4019649ed81fa6b    refs/tags/v0.0.2.1

Does anyone know what is going on?

I have found a workaround: The following works:

 git pull origin refs/tags/v0.0.2.1

This works for my task, but I would really like to understand more about why this works and the other approach doesn't. If anyone can provide an explanation that would be awesome.

When reading the changelogs of git 's version 1.7.0 to 1.7.9 we can find several entries which might lead to the explanation. The way ref-lookups are done on the remote-side has changed (to speed up things).

This can explain why version 1.7.0 needs refs/tags/<tagname> for fetching and 1.7.10 doesn't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM