Git submodule reset8/10/2023 ![]() ![]() ![]() Then, having done that, use git checkout tags/v2.11.0 or git switch -detach tags/v2.11.0, which will complain if there is uncommitted work. Overall, it is probably more sensible to run git fetch -tags, without -all, to fetch from the current remote, or to pick a specific remote to trust or if there's only one remote, git fetch -tags will use that one remote and then -all is unnecessary. If you are on a branch name, this alters the stored hash ID in that branch name, which is probably wrong. If you're already on a detached HEAD, this is like doing a git checkout of the given tag, with the side effect of throwing away any work that has not yet been committed. ![]() The git reset -hard is likely the wrong thing to do. If there are conflicts-if remote A says that tag v1.2.3 should mean deadbeef and remote B says that tag v1.2.3 should mean feedf00d, whichever one you pick up first "wins", in general. This makes a little bit of sense in the context in which you're using it, since each remote could have some set of tags, and this would get your Git to copy all of their tags, into a massive tag-union. Be aware that this will discard all non-committed changes. To make the submodule itself recursively check out any of its own submodules.ġThe -all option to git fetch means fetch from all remotes. Move into the submodule's directory, then do a git reset -hard to reset all modified files to their last committed state. Or: git submodule update -recursive checkout If you want to make each submodule be a detached HEAD at that commit, you would now run: git submodule update checkout That Git's index now holds, as a path-name-and-hash-ID pair like path/to/submodule and feedc0ffee., the commit that one might want the submodule to git checkout (as a detached HEAD). Checking out the superproject commit results in putting that gitlink into the superproject Git's index. That's part of the commit itself, as an entity that Git calls a gitlink. (The full hash ID is long and ugly, but you can find it with: git rev-parse tags/v2.11.0Ī normal way to use a superproject is to have, in the superproject commit, the correct hash ID for each submodule. That's a lot of what you're doing with Git: you might use a branch name like master or develop or whatever, or a tag name like v2.11.0, but you're really telling Git get me commit b0ff0cab1e. Some other repository's tag is a name for some hash ID in that repository. If you don't have the tag, you don't have that name. A tag is just a name for a commit hash ID, and in any given repository, you either have the tag, or you don't. I presume that this means that each submodule has no such tag. That separate Git repository may or may not have a tag v2.11.0 if it does have such a tag, that tag will represent some other commit that exists in that other Git repository: Is a little weird, 1 but not entirely crazy.Įach submodule, though, is a separate Git repository. The tags/v2.11.0 tag in the superproject is therefore a name for-that is, represents the number, or hash ID of-a particular commit in the superproject. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |