Reputation: 5570
git fetch a tag from a remote, but could not see it local.
git remote add remote1 c:\repo\project1.git
git fetch remote1 tag_1.0
From c:\repo\project1
* tag tag_1.0 -> FETCH_HEAD
git tag
git tag does not show the fetched tag tag_1.0. How to list the tag and create a branch from the tag?
Upvotes: 1
Views: 112
Reputation: 30868
To create a local tag tag_1.0
,
git fetch remote1 tag_1.0:refs/tags/tag_1.0
And then to create a branch foo
from the tag,
git branch foo tag_1.0
After git fetch remote1 tag_1.0
, the commit referenced by the tag is stored in FETCH_HEAD
. So, we can also create the local tag and branch based on FETCH_HEAD
.
git fetch remote1 tag_1.0
# There should be no other fetch/pull commands here, otherwise FETCH_HEAD could be rewritten by another commit
git tag tag_1.0 FETCH_HEAD
git branch foo FETCH_HEAD
Upvotes: 2