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?
You should look into Git submodules. It should allow almost exactly what you're looking for.
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.
For the latest version of Git I'd suggest to read about Git submodules in the official Git documentation.
As I mention in "Git submodule new version update", you can achieve the same SVN external feature with Git 1.8.2 submodules:
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:
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".