Maintaining a git repository containing other cloned git repositories

I am working on a website using Sharelatex (github) , but it contains other repositories that are used to create the main project. I cloned the main repository and did grunt install , which is used to download these repositories.

But the problem is that I need to change the code both in the main repository and in the downloaded one.

Since these projects may receive new updates, I want to combine these changes. I also need to maintain the repo, but when I push the changes to Github, it only shows the changes to the main repo.

I met submodules in git, but since the main project does not contain submodule types, I cannot use it.

For instance:

The main project uses the web repo. I start with some changes to the files on the web . I need these changes reflected in my remote repository so others can use them.

Now suppose that after a while an important update for web repo appears, how do I use it?

I enter grunt install on the command line to download this repo. It does not create a submodule, but clones this repo into my folder, which is subsequently ignored by my main git repo.

The question may seem unclear, but I tried my best to explain this problem.

In a nut shell:

  • I want to not only make changes to both the main repo and any other repo that was involved, but to pull and merge other repositories, as well as when their updates are available.

  • I also need to support the remote repo of my project.

+6
source share
1 answer

I am working on a site using Sharelatex (github), but it contains another repository that is used to create the main project. [...] I met submodules in git, but since the main project does not contain any submodules, I cannot use this.

Actually, you have a submodule. What a nested repository is, and (I'm serious about that), as far as you need to understand, in order to fine-tune the submodules, that everything is in the submodules. To understand the submodules, imagine that you have a nested repository (you do), and think about the administrative requirements that you need to do to support this setting in dvcs.

Firstly, when people clone a project that uses submodules from a certain repo, you all decide to contain published commits, this clone, obviously, also will not receive the subproject repository (of course, it should not receive your personal and divine knowledge - that you done-up-version). Therefore, they should also get a subproject repository from one of their published repositories.

How do you tell people collecting your commits where to get the necessary subprojects? It’s clear that you need to drop the note somewhere in the commit file, which says: “There is a repo here that should have any necessary $ subproject”. git submodule installed .gitmodules as the usual place to store notes like this.

Next: OK, what should others do if the URL you gave them is disabled? They just need to use another repo. Therefore .gitmodules are just sentences, the git submodule uses the current values ​​in your .git/config , which git submodule init populates from those suggested in .gitmodules`.

Operations

git submodule all like that. Forget it. Don't even look at the team until you need a little help that does what you already found fit. Start with the knowledge, the simple fact that a submodule is nothing more than a nested repo, and the project used with it is nothing but a commit identifier, which should be somewhere in this nested repo. It. This is all a submodule.

When you do the tedious tasks you need, find the git submodule subcommand that will do them for you. You do not need to use a subcommand. All this subcommand makes automation of simple tasks that would be laborious otherwise. This is a toolkit for doing what you need to do, and there is no way on earth, it could or should impose some arbitrary and sufficient abstraction (in that the heavy part) on everyone in the world. So this is a grab bag.

However, there is one important security game git submodule update and git submodule add for you when they make git clone for you. Repositories usually have the actual repo contents in the [sub] toplevel .git project, but if you check a branch that does not have this subproject or not, or want this subproject to go away, its .git will also disappear - not what you want when it stores not only the content you have issued but the entire actual repo. Therefore, when git submodule update makes its initial clone, it pushes the .git submodule .git into a convenient (and arbitrary) small corner in the repo containing project and replaces the .git directory that it just pulled out of the submodule with .git containing the relative path to the moved directory.

To get this initial upgrade done on the repo you have, move it from your current repo, add and update it where you put it, and then correct the upstream URLs in .gitmodules for the convenience of others.

There. Now you know absolutely everything you need to know in order to understand the w20> submodules and gradually get the details only as you find that you need them to understand what the git submodule command git submodule for you, and why you really business does not need to worry about understanding every little detail in its attic in front. At least I think so.

If I missed something important, I would be very glad (tender or dumb, I do not care) corrections in the comments.

+6
source

Source: https://habr.com/ru/post/976990/


All Articles