Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

Why might git describe always return `fatal: No tags can describe SHA1` after I converted a svn repo to a git repo?

I am trying to convert a svn repo to a git repo. I therefore followed the second (most upvoted) answer of a previous SO question. I only diverged by converting svn tags to git tags and created annotated, not lightweight tags, like so:

git checkout -b tag_v1 remotes/tags/v1
git checkout master
git tag -a v1 tag_v1 -m "release"
git branch -D tag_v1

After I converted the repo, I tried to describe the git tags, as follows:

git describe

However, I only receive the following error message in return:

fatal: No tags can describe <SHA>

In addition, when I try to look at the ancestry-path from a commit related to a tag to the current HEAD as,

git rev-list --ancestry-path <SHA RELATED TO TAG>..<SHA RELATED TO HEAD>

I receive an empty response. In accordance to the accepted answer from this SO question, I made sure to fetch all remote branches. In response to the second (most upvoted answer) I also made sure that each tag is associated with a commit message. Git showfor a particular tag reveals:

tag A
Tagger: foo
Date:   bar

release

commit d1c276a83a4e21dc26e019905db9a237e1366013 (tag: A)
Author: baz
Date:   bazbaz

    Created a tag for version 2.8.0

Does somebody know why git describe always return the error message? I am grateful for any hints or suggestions!


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

1 Answer

0 votes
by (71.8m points)

I think I have figured out the answer for this question after some long trial and error. The code to create tags when migrating a svn repo to a git repo instructs creating branches for each tag, like so

git checkout -b tag_v1 remotes/tags/v1
git checkout master
git tag -a v1 tag_v1 -m "release"
git branch -D tag_v1

These branches are effectively never merged into the master branch again and seem to be "orphaned" to me. I think git describe thus does not find a path between them.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...