Reputation: 6188
Please note that I am new to Git.
I have two repos:
The main repository is Libgdx REPO and all of my work goes into this repository, mainly in the gdx-sqlite project. Since I wanted gdx-sqlite project to appear as a separate repository, what I did was:
This resulted in everything going wrong and I assumed that nested repository was the main culprit. Later I deleted the local nested repository and reverted to a previous commit. I have found out that a solution to this kind of problem is Git Submodules but I am completely lost at what I am trying to achieve which is as follows.
Now how am I supposed to achieve this in light of the following:
How can this be made possbile?
Upvotes: 3
Views: 2349
Reputation: 135
This worked for me:
git ls-files --stage | grep $160000
Based on this great article: http://www.speirs.org/blog/2009/5/11/understanding-git-submodules.html
Upvotes: 0
Reputation: 1151
You should take a look at git subtree. This allows you to add one or more git repository as subtrees.
One of the drawbacks is, that you need to be carifully with your commits. If you commit several changes with files in different sub trees, than all the repositories will have this commit in its history. This can be really nasty if you try to pin down a change in one repo and can not find the file mentioned in the log because the file never belonged to this repo. A solution is to split commits to the different repositories.
Upvotes: 2
Reputation: 7332
You're right. The good approach for this kind of situation is to use Git submodules. This is the best way to handle dependencies in Git.
As gdx-sqlite is an extension of your main project Libgdx, you could do it this way to add it as a submodule:
git clone [email protected]:mrafayaleem/libgdx.git libgdx
cd libgdx
# remove the old directory
rm -rf extensions/gdx-sqlite
git add extensions/gdx-sqlite
# add the submodule (note the read-only URL)
git submodule add git://github.com:mrafayaleem/gdx-sqlite.git extensions/gdx-sqlite
# commit the changes
git commit -m 'Add submodule for the gdx-sqlite extension'
Then to clone your project (and all its submodules):
git clone --recursive git://github.com/mrafayaleem/libgdx.git
Or for you (with write access):
git clone --recursive [email protected]:mrafayaleem/libgdx.git
Upvotes: 6