![]() Hence what’s obvious for you often is not the right thing in all possible technical situations. Reliability in each and every situation is far more important. This is because “obvious” here depends from the point of view. So I understand complaints of people, saying “Why doesn’t do git the obvious thing for me”. git is a tool, which must do a reliable job, instead of being just another “Eierlegende Wollmilchsau” (“Eierlegende Wollmilchsau” translates for me to “some evil version of a Swiss army knife”). This truly is puzzling to newcomers, but basically is a good thing: git just does the obviously thing and does that right, and does not even try to do more. Also “pulling in the data” is implicit, because you need it, but removing the cached information is not done, because this is not needed at all and might wipe precious data. There simply is no need for more than two commands. This cannot be fully symmetric, as keeping it strictly symmetric does not make much sense. (3) checks out the submodules of the submodule recursively.git submodule update -init -recursive - module.(2) does git submodule update, so, nonrecursively checks out the module.(1) does git submodule init, so updates.(3) thereby recursively removes the submodules of the submodule.Git submodule update -init -recursive - moduleīecause some commands basically need to do more than just a single thing: In my understanding this is not only plain wrong, it is extremely dangerous and provokes major headaches in future! See below.Īlso is quite the inverse to git submodule add - URL module It recommends to remove $GIT_DIR/modules// yourself. I think there is a very dangerous part in the documentation of git submodule. Like a proper way to remove submodules again. Stay away at all cost!Īnd yes, you can blame git for this, as many handy things were missing in git in the past. If on Windows ignore the first line and replace "$submodule" with the Windows way of a properly specified path to the submodule."$submodule" is just to emphasize where to put the name, and that you have to be careful with spaces and the like.If this does not work for you, see below.Following is the tested and safe way for git version 2.17 and above to get rid of a submodule: submodule="path/to/sub" # no trailing slash! You'll want to change the remote URL of this module directory to your new submodule repository, which is typically named "origin.For the benefit of the reader, this here tries to sum it up and give a step-by-step guide on how to do it if things do not work as expected. This will let you transfer over all the Git history related to that submodule. ![]() You'll be left with only the code that was in the directory, and only the commits pertaining to it. Git filter-branch -subdirectory-filter submoduledirectory -all This is a destructive operation, so make sure you're doing this on the copy of your repo, not the main one. ![]() This will delete all the commit history that isn't related to the code contained in the submodule. ![]() Next, you will want to filter out everything that isn't related to your submodule. Next, you will want to get a fresh copy of your main repository to make the submodule repository from. This is usually on a Git hosting service like GitHub, though you can create a local repository on your computer. The first step is to create a new repository for the submodule. Instead, we'll clone the repository, filter out the unneeded code, and push the new history to the new submodule. ![]() You can copy the code to a new folder, but you will lose all the Git history related to it, which can be very detrimental in large projects. Git expects you to create a new empty directory for it, and clone the submodule into the project. One of the main problems with turning an existing directory into a submodule is that the submodule should be managed externally. However, this doesn't work for all types of projects, and if you're working with private code, you'll need to set up a private package registry, which can be more complicated than simply embedding the library's source code as a submodule. This means that the submodule's code and Git history is kept separate from the main version control, and can be updated for multiple repositories that consume the library.Īn alternative to submodules is to publish your libraries as packages to package managers like NPM, Maven, or NuGet. When you clone the parent repository, it automatically clones the submodule repository as well. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |