我决定将我的应用程序存储库从 SVN 切换到 git。
我的回购结构是这样的:
~/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
如您所见,我有很多库,我的应用程序的核心位于MyMine
folder.
我已将库添加为 git 子模块:
~/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
现在,假设我对其中一个库/子模块进行了更改。但我不想将这些更改推到其根源,因为:
- 作者可能/将会拒绝我的提交
- 我的改变只与我相关
- 我的更改只是一行修改,以适应代码,以便它在我的项目中编译
然而,我do想要的是将我的提交(对这些子模块进行的)推送到我的项目的起源。这是因为这些更改对于编译我的项目是必要的。因此,如果我决定将完整的存储库克隆到新的开发机器,我希望它们位于存储库中。或者,如果一个新人加入团队并需要设置其开发机器。
因此,我已提交对其中一个库所做的修改。然后,我将相应的子模块提交到我的存储库,并将其推送到原点。
问题在于,在(我的服务器的)源上,子模块项目指向错误的快照,因为该快照仅存在于我的本地存储库上,而不存在于源上。我无法推送它,因为 git 会尝试将提交推送到子模块的原点,而这不是我项目的原点。
如何提交对子模块所做的更改,并从我的主存储库中获取这些更改?所有这些都没有将子模块推到其原点?
如果我使用的术语或方法看起来愚蠢或不合适,我深表歉意。正如我所说,我正在尝试切换到 git,即使我花了一些时间阅读 git 书籍,我也可能误解了一些流程或词汇。