2

Im new at git and i don't have idea to do that.

Im building a template, which have a module pack and the module pack contains modules.

The modules can be instalated for separate and can have multiple versions of the same module (pro, simple..). (I think i can do branch in my module folder).

The pack of modules can instaled without template but need to have modules inside with the last version of they and this pack modules can have a version too, for example version one include module 1,2,3 ...

And finaly i have the template which have files too and the package of modules which have to had the last version of them.

In resume, i need to controll versions of all together and separate, but i have to had all of them in the same place

I think I could do this

 -- Template (git folder) -- Module pack (git folder) -- Module 1 (git folder) -- Pro version (branch) -- Simple version (branch) -- Module 2 (git folder) -- .... 

Is this posible or I should think in other methods ? Thank you.

2
  • We have no idea of what you mean by template or module. git doesn't know and care about what you store in a repo. You can store any kind of file you want, and create whatever branches you find useful to create. Don't confuse the sources, stored in git, and the artifacts that your build procedure creates, which are normally not stored in git. Commented Dec 29, 2018 at 13:38
  • 1
    git submodules, The Book, git subtrees. Commented Dec 29, 2018 at 14:25

1 Answer 1

4

I just have a solution for your problem - gil (git links) tool

It allows to describe and manage complex git repositories dependencies.

Also it provides a solution to the git recursive submodules dependency problem.

Consider you have the following project dependencies: sample git repository dependency graph

Then you can define .gitlinks file with repositories relation description:

# Projects CppBenchmark CppBenchmark https://github.com/chronoxor/CppBenchmark.git master CppCommon CppCommon https://github.com/chronoxor/CppCommon.git master CppLogging CppLogging https://github.com/chronoxor/CppLogging.git master # Modules Catch2 modules/Catch2 https://github.com/catchorg/Catch2.git master cpp-optparse modules/cpp-optparse https://github.com/weisslj/cpp-optparse.git master fmt modules/fmt https://github.com/fmtlib/fmt.git master HdrHistogram modules/HdrHistogram https://github.com/HdrHistogram/HdrHistogram_c.git master zlib modules/zlib https://github.com/madler/zlib.git master # Scripts build scripts/build https://github.com/chronoxor/CppBuildScripts.git master cmake scripts/cmake https://github.com/chronoxor/CppCMakeScripts.git master 

Each line describe git link in the following format:

  1. Unique name of the repository
  2. Relative path of the repository (started from the path of .gitlinks file)
  3. Git repository which will be used in git clone command
  4. Repository branch to checkout

Empty line or line started with # are not parsed (treated as comment).

Finally you have to update your root sample repository:

# Clone and link all git links dependencies from .gitlinks file gil clone gil link # The same result with a single command gil update 

As the result you'll clone all required projects and link them to each other in a proper way.

If you want to commit all changes in some repository with all changes in child linked repositories you can do it with a single command:

gil commit -a -m "Some big update" 

Pull, push commands works in a similar way:

gil pull gil push 

Gil (git links) tool supports the following commands:

usage: gil command arguments Supported commands: help - show this help context - command will show the current git link context of the current directory clone - clone all repositories that are missed in the current context link - link all repositories that are missed in the current context update - clone and link in a single operation pull - pull all repositories in the current directory push - push all repositories in the current directory commit - commit all repositories in the current directory 

More about git recursive submodules dependency problem.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.