Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How does one reference a tag number in a .gitmodule file?

boonehm January 3, 2023

Ultimately, I am wanting to point a submodule in my .gitmodule to a specific tag on the repository that houses the submodule. I know you can't outright specify a "tag" attribute or list the tag in the "branch" attribute. Is there a workaround to do something like this?

In my testing, I am currently experiencing issues with testing if the url path to the tag from the source repo can be used in the "URL" attribute. In attempts to follow the steps found in this answer: https://confluence.atlassian.com/bbkb/bitbucket-cloud-fix-error-fatal-no-url-found-for-submodule-path-in-gitmodules-1188400518.html, when running 'git submodule status' I receive the error that "no submodule mapping found in .gitmodules for path 'path/name'". When running 'git rm --cached old/path', I receive the error "fatal: pathspec 'old/path' did not match any files, although I have only used one path name for this submodule. Since that didn't seem to work, the step to update submodules once again, of course, fails still, stating that there is no url found for the "old/path" even though it claims the path name cannot be found in the pathspec, it is as if it is still referencing the path name.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 4, 2023

Hi @boonehm and welcome to the community!

I don't think that a url in .gitmodules set to something like https://bitbucket.org/my-workspace/my-repo/commits/tag/1.4 is going to work. This is not a valid url for cloning a submodule.

A tag is always associated with a specific commit. A branch is a pointer to a commit.
You can create a new branch out of the commit that the tag is pointing to with:

git checkout -b NEW_BRANCH_NAME COMMIT_HASH

and then use that's branch's name in the "branch" attribute in .gitmodules.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events