At Catalyst we’ve been using Git for several years (since its infancy)… and we currently use git-submodule to install plugins for Rails, Drupal, and Moodle.
The scenario
A common path I follow goes something like this:
- Install plugin direct from a remote repo
- Work happily with it (unmodified) for a while
- Find a bug or need to modify (ARRRGH)
- Fork the original repo, patch… and switch to our fork.
This final step can be a bit of a pain to manage in git-submodule. I do something like this:
Switching over
1. Modify .gitmodules to to change the reference from old to new repo
vim .gitmodules
2. Use git submodule sync
git submodule sync
3. Get into the repo and change references in .git/config to point to new repo
cd path/to/submodule
vim .git/config #and make changes
git remote update
4. Commit any uncommitted changes and push it to your remote (I’m assuming that this is properly configured) – something like
git commit -am "fix scary bug"
git push origin master
git remote update
5. Add the old repo as a remote
git remote add upstream git://github.com/upstream_user/the_submodule.git
git remote update
6. Switch back to the main repo, add and commit .gitmodules and the actual submodule.
You’re done. Let me know if you have any hassles with it.