每个ref的git与标记的实际数量不匹配

每个ref的git与标记的实际数量不匹配,git,svn,git-svn,Git,Svn,Git Svn,我按照这条指令尝试将现有的svn存储库迁移到git。 我使用命令克隆了存储库 git svn clone https://urltorepository.com/svn/repos-itservices/apps --no-metadata --authors-file=authors.txt --stdlayout testing 当我为每个refgit时,我得到以下结果: f98b1954059631270b44ed3037d3d08127ab051a commit refs/remot

我按照这条指令尝试将现有的svn存储库迁移到git。

我使用命令克隆了存储库

git svn clone https://urltorepository.com/svn/repos-itservices/apps --no-metadata --authors-file=authors.txt --stdlayout testing
当我为每个ref
git时,我得到以下结果:

f98b1954059631270b44ed3037d3d08127ab051a commit refs/remotes/tags/RE.15.03.00.00
181a447b465c34857c1091b06173d30f467c9941 commit refs/remotes/tags/RE.15.03.00.01
cfca76149b8f79749ef0e978b3628fdcf43955d0 commit refs/remotes/tags/RE.15.04.00.00
bc19d96df3a95ae82368ac2083dc1cb77b39a2e9 commit refs/remotes/tags/RE.15.05.00.00
9cdf10ed94bcd5f88f121cb7977da79551918a7f commit refs/remotes/tags/RE.15.11.00.00
3d51a5ca903965b6043744c4995b3c17268c516b commit refs/remotes/tags/RE.16.03.00.00
83e65bbc68435b5622691acbaeba7e575bed08e4 commit refs/remotes/tags/RE.16.04.00.00
281e7aab7adc0d73fc678a39524cd8b64130fdfa commit refs/remotes/tags/RE.16.05.00.00
...
...
0cbf2d48633b5c8d691bf4b93208f02de0cd94fa commit refs/remotes/tags/RE.17.11.00.00
b57de4c3bc4caf4c77f2deb5eb10121193d39122 commit refs/remotes/tags/RE.17.11.10.00
1be3ba34cc0c0f556f972c6407605b560ad32f57 commit refs/remotes/tags/RE.18.01.00.00
56199738b9b4c523c7fc5daf00a3b7bd111f34f7 commit refs/remotes/tags/RE.18.02.00.00_IRIS-MIG
436823909e35cc78813042e1a2181048628e006d commit refs/remotes/tags/RE.18.03.00.00
f4edf4871858f180de3bae7c6dd04d1281e7a0f0 commit refs/remotes/tags/RE.18.03.00.00_ROLLBACK
4e38260f293ceb77281f0f87bd5816b48d0df174 commit refs/remotes/tags/RE.18.04.00.00
fcd58a4f0abf1b8dbb7d9edc846a831b964b09e4 commit refs/remotes/tags/RE.18.05.00.00
4e8936901052fd84804c7587cdb9c21ab980fc0e commit refs/remotes/tags/RE.18.06.00.00
18d443117221769ebccd42a1b22b06e039984c81 commit refs/remotes/tags/RE.18.08.00.00
8bfcb5f9c0b8d27f84e00ed5a2c4574cf726b357 commit refs/remotes/tags/RE18.06.00.00
6bb64c124aa47361c1fb951e6f6132ca09900b3f commit refs/remotes/tags/backup
b84d777d172d56bb43a18f9216cdfd48715cc76f commit refs/remotes/tags/backup@15657
a071ef00e51484338d1d8ee378f63a891d5e327b commit refs/remotes/tags/mod-security-2.2.7-test
5b0bd14307822551d65f1eabf06a229ac80cb0f2 commit refs/remotes/tags/mod-security2.2.7-testing
80b983c042b9ce5ce4c4b79fe02f1e4dec4785c5 commit refs/remotes/tags/package
568bf833abe733ebed65a0f2274826745c1c20bd commit refs/remotes/tags/package@15657
67155be3306148cc726711ec69092af4eba10845 commit refs/remotes/tags/props
f14622fc103a2c6ad1836c8a5d747f13936f5f7a commit refs/remotes/tags/props@15657
2c44a37dd69f45c58aabca388266232cfbbf108a commit refs/remotes/tags/rp
720d43aba7666cd9727d049dc3e04bc9827e4523 commit refs/remotes/tags/rp@15657
6bb64c124aa47361c1fb951e6f6132ca09900b3f commit refs/remotes/tags/tmp
b84d777d172d56bb43a18f9216cdfd48715cc76f commit refs/remotes/tags/tmp@15657
12d372c97e17f10ec5daba08debaf3e0fa887356 commit refs/remotes/trunk
但是当我检查这个文件夹时,我看到里面只有很少的标签

$> ls -a .git/refs/remotes/tags/
.   RE.17.08.00.00  RE.17.11.10.00  RE.18.01.00.01  RE.18.02.00.00_IRIS-MIG  RE.18.03.00.00_ROLLBACK  RE.18.05.00.00  RE18.06.00.00
..  RE.17.10.00.00  RE.18.01.00.00  RE.18.02.00.00  RE.18.03.00.00           RE.18.04.00.00           RE.18.06.00.00  RE.18.08.00.00
有人能告诉我为什么会有这种区别吗

更新

我将这些标签添加到我的git中,然后执行了
git推送--tag

$> git for-each-ref --format='%(refname)' refs/remotes/tags | egrep "RE*" | cut -d / -f 4- | while read ref; do git tag -a "$ref" -m "$ref"; done
$> git tag
RE.12.04.00.00
RE.12.05.00.00
RE.12.06.00.00
RE.12.07.00.00
...
...
RE.18.02.00.00
RE.18.02.00.00_IRIS-MIG
RE.18.03.00.00
RE.18.03.00.00_ROLLBACK
RE.18.04.00.00
RE.18.05.00.00
RE.18.06.00.00
RE.18.08.00.00
RE18.06.00.00
然后,在我的git存储库中,我有以下内容:

f98b1954059631270b44ed3037d3d08127ab051a commit refs/remotes/tags/RE.15.03.00.00
181a447b465c34857c1091b06173d30f467c9941 commit refs/remotes/tags/RE.15.03.00.01
cfca76149b8f79749ef0e978b3628fdcf43955d0 commit refs/remotes/tags/RE.15.04.00.00
bc19d96df3a95ae82368ac2083dc1cb77b39a2e9 commit refs/remotes/tags/RE.15.05.00.00
9cdf10ed94bcd5f88f121cb7977da79551918a7f commit refs/remotes/tags/RE.15.11.00.00
3d51a5ca903965b6043744c4995b3c17268c516b commit refs/remotes/tags/RE.16.03.00.00
83e65bbc68435b5622691acbaeba7e575bed08e4 commit refs/remotes/tags/RE.16.04.00.00
281e7aab7adc0d73fc678a39524cd8b64130fdfa commit refs/remotes/tags/RE.16.05.00.00
...
...
0cbf2d48633b5c8d691bf4b93208f02de0cd94fa commit refs/remotes/tags/RE.17.11.00.00
b57de4c3bc4caf4c77f2deb5eb10121193d39122 commit refs/remotes/tags/RE.17.11.10.00
1be3ba34cc0c0f556f972c6407605b560ad32f57 commit refs/remotes/tags/RE.18.01.00.00
56199738b9b4c523c7fc5daf00a3b7bd111f34f7 commit refs/remotes/tags/RE.18.02.00.00_IRIS-MIG
436823909e35cc78813042e1a2181048628e006d commit refs/remotes/tags/RE.18.03.00.00
f4edf4871858f180de3bae7c6dd04d1281e7a0f0 commit refs/remotes/tags/RE.18.03.00.00_ROLLBACK
4e38260f293ceb77281f0f87bd5816b48d0df174 commit refs/remotes/tags/RE.18.04.00.00
fcd58a4f0abf1b8dbb7d9edc846a831b964b09e4 commit refs/remotes/tags/RE.18.05.00.00
4e8936901052fd84804c7587cdb9c21ab980fc0e commit refs/remotes/tags/RE.18.06.00.00
18d443117221769ebccd42a1b22b06e039984c81 commit refs/remotes/tags/RE.18.08.00.00
8bfcb5f9c0b8d27f84e00ed5a2c4574cf726b357 commit refs/remotes/tags/RE18.06.00.00
6bb64c124aa47361c1fb951e6f6132ca09900b3f commit refs/remotes/tags/backup
b84d777d172d56bb43a18f9216cdfd48715cc76f commit refs/remotes/tags/backup@15657
a071ef00e51484338d1d8ee378f63a891d5e327b commit refs/remotes/tags/mod-security-2.2.7-test
5b0bd14307822551d65f1eabf06a229ac80cb0f2 commit refs/remotes/tags/mod-security2.2.7-testing
80b983c042b9ce5ce4c4b79fe02f1e4dec4785c5 commit refs/remotes/tags/package
568bf833abe733ebed65a0f2274826745c1c20bd commit refs/remotes/tags/package@15657
67155be3306148cc726711ec69092af4eba10845 commit refs/remotes/tags/props
f14622fc103a2c6ad1836c8a5d747f13936f5f7a commit refs/remotes/tags/props@15657
2c44a37dd69f45c58aabca388266232cfbbf108a commit refs/remotes/tags/rp
720d43aba7666cd9727d049dc3e04bc9827e4523 commit refs/remotes/tags/rp@15657
6bb64c124aa47361c1fb951e6f6132ca09900b3f commit refs/remotes/tags/tmp
b84d777d172d56bb43a18f9216cdfd48715cc76f commit refs/remotes/tags/tmp@15657
12d372c97e17f10ec5daba08debaf3e0fa887356 commit refs/remotes/trunk

正如您所看到的,所有标记都与上次提交相关

引用(例如标记)可以作为单个文件存储在
.git/Refs/**
中,也可以作为“打包引用”存储在单个文件“.git/packed Refs”中


更新-编辑此问题是为了添加一些关于根据
RE*
refs尝试添加标记的信息。此时,您似乎真的在问如何为每个引用创建标记;请清楚地陈述你的实际问题,而不是让我们猜测你想知道什么

因此:标记是指向数据库中某个对象的引用,它恰好位于
refs/tags/
名称空间中。按照惯例,这个名称空间中的引用不应该“四处移动”(如果有的话,也不应该太多),它们会成为指向的对象的“名称”

git tag
命令将ref应该指向的对象的ID或解析为该对象的表达式作为参数。您没有给出该参数,因此它使用默认值,即
HEAD
(当前已签出的提交)

(由于所用参数的顺序不同,可能不太明显您忽略了目标。但您给出的是一个
-a
选项,然后是一个标记名,然后是一个
-m
选项,带有与标记名匹配的注释。)

而不是

git for-each-ref --format='%(refname)' refs/remotes/tags | egrep "RE*" | cut -d / -f 4- | while read ref; do git tag -a "$ref" -m "$ref"; done
你可以试试

git for-each-ref --format='%(refname)' refs/remotes/tags | egrep "RE*" | cut -d / -f 4- | while read ref; do git tag -a -m "$ref" "$ref" "refs/remotes/tags/$ref"; done

(注意,因为您正在创建一个带注释的标记,ref实际上将指向一个新的
标记
对象,该对象反过来将指向正确的提交。这是正常的,但请注意ref看起来不会指向您可能期望的ID。)

很有趣,但是如何将这个ref转换为真正的git标记呢?我在read-ref-do-git标记-a$ref时为每个ref尝试了类似于
git的东西;完成了
,但是我得到了一个非常奇怪的标签,它与承诺没有联系,因为信息丢失了,所以不适合后续提问。请确保您的问题包含您正在寻找的信息。我看到你对这个问题进行了一些后续更新(我通常也不鼓励这样做,因为在未来人们搜索信息时,对不断变化的问题的现有答案变得令人困惑)。我会根据问题的当前形式更新我的答案,但如果您继续发现更多相关问题,我建议您进行研究,然后在适当的情况下发布新的问题树。我没有找到有关它的信息,但我将创建新问题。谢谢谢谢你的最新答案。根据您的建议,我在命令中添加了额外的
“$ref”
,然后我得到了所有ref的错误:
致命:未能将“RE18.06.00.00”解析为有效的ref。
注意
RE18.06.00.00
对于每个错误都是不同的哦。正确的。额外的
$ref
实际上应该是
refs/remotes/tags/$ref
。在上面编辑的同时,我这次也对选项进行了重新排序,使其更加直观。(正如最初编写的,第一个
$ref
似乎是
-a
选项的参数,但
-a
不接受参数。)