I have decided to switch from SVN to git for my app repository.
My repo structure is like this:
~/AndroidStudioProjects/MyMine $ tree -L 1
.
├── ActionBarSherlock
├── Android-Universal-Image-Loader
├── Android-ViewPagerIndicator
├── Crouton
├── ListViewAnimations
├── MyMine
├── SlidingMenu
├── aFileChooser
├── drag-sort-listview
└── out
10 directories, 0 files
As you can see, I have plenty of libraries, and the core of my app is in the MyMine
folder.
I have added the libraries as git submodules:
~/AndroidStudioProjects/MyMine $ cat .gitmodules
[submodule "ActionBarSherlock"]
path = ActionBarSherlock
url = https://github.com/JakeWharton/ActionBarSherlock.git
[submodule "Android-Universal-Image-Loader"]
path = Android-Universal-Image-Loader
url = https://github.com/nostra13/Android-Universal-Image-Loader.git
[submodule "Android-ViewPagerIndicator"]
path = Android-ViewPagerIndicator
url = https://github.com/JakeWharton/Android-ViewPagerIndicator.git
[submodule "Crouton"]
path = Crouton
url = https://github.com/keyboardsurfer/Crouton.git
[submodule "drag-sort-listview"]
path = drag-sort-listview
url = https://github.com/bauerca/drag-sort-listview.git
[submodule "ListViewAnimations"]
path = ListViewAnimations
url = https://github.com/nhaarman/ListViewAnimations.git
[submodule "SlidingMenu"]
path = SlidingMenu
url = https://github.com/jfeinstein10/SlidingMenu.git
[submodule "aFileChooser"]
path = aFileChooser
url = https://github.com/iPaulPro/aFileChooser.git
Now, let's say I make changes to one of the libraries/submodules. But I don't want to push those changes to their origin, because:
However, what I do want is to push my commits (made to those submodules) to my project's origin. This is because those changes are necessary for compiling my project. So I want them to be in the repo if I decide for example to clone the full repo to a new development machine. Or if a new guy comes to the team and needs to setup its development machine.
So, then, I have committed the modifications made to one of the libraries. Then, I committed the corresponding submodule to my repository, and pushed it to the origin.
The problem is that on the origin (of my server), the submodule projects points to a wrong snapshot, because that snapshot is only existing on my local repo, and not on origin's. And I can't push that, because git would try to push the commits to the submodule's origin, which is not my project's origin.
How can I commit changes made to a submodule, and have those changes available from my main repository? All of that without pushing the submodule to its origin?
I apologize if the terminology or the methods I use seem dumb or aren't appropriate. As I said, I'm trying to switch to git, and even if I spent some time reading a git book, I may have misunderstood some of the processes or vocabulary.
You can't do that, as far as I know.
You'll need to fork the submodule repo and point your project's submodule at the fork instead of the current location. Then you can push your updates to your fork, maintain them there, and your main project can point to your changes.
The other option you have is to just maintain your changes as patches and have your build system apply them before compiling.
Maybe someone will come along with a neat trick for you.