I have two SVN projects in use from another SVN repository using svn:externals.
How can I have the same repository layout structure in Git?
I have two SVN projects in use from another SVN repository using svn:externals.
How can I have the same repository layout structure in Git?
Git has two approaches similar to, but not exactly equivalent to svn:externals:
Subtree merges insert the external project's code into a separate sub-directory within your repo. This has a detailed process to set up and then is very easy for other users, because it is automatically included when the repository is checked out or cloned. This can be a convenient way to include a dependency in your project.
It is easy to pull changes from the other project, but complicated to submit changes back. And if the other project have to merge from your code, the project histories get merged and the two projects effectively become one.
Git submodules (manual) link to a particular commit in another project's repository, much like svn:externals with an -r argument. Submodules are easy to set up, but all users have to manage the submodules, which are not automatically included in checkouts (or clones).
Although it is easy to submit changes back to the other project, doing so may cause problems if the repo has changed. Therefore it is generally not appropriate to submit changes back to a project that is under active development.
svn:externals. With revision 1.5, the syntax was changed to a more flexible format. What was added was relative URL addressing.As I mention in "Git submodule new version update", you can achieve the same SVN external feature with Git 1.8.2 submodules:
git config -f .gitmodules submodule.<path>.branch <branch> This is enough for a submodule to follow a branch (as in the LATEST commit of a remote branch of a submodule upstream repo). All you need to do is a:
git submodule update --remote That will update the submodule.
More details are in "git submodule tracking latest".
To convert an existing submodule into one tracking a branch: see all the steps in "Git submodules: Specify a branch/tag".
svn:externals?--depth but it doesn't really address the problem.I'm the author of gil (git links) tool
I have an alternative solution for the 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:
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.
gil.
git submodulecan now emulatesvn:external(since March 2013).