Updating a git submodule from a forked repo on GitHub
Git submodules are a great way of adding 3rd-party libraries/modules to your project.
Basically you are forking the 3rd-party repo and add your own fork as submodule to your projects.
The benefits are that you can modify the fork to your needs and even open pull requests to the maintainer. If the maintainer updates his code you can then merge/update everything you want into your fork and keep your patches that didnt make it upstream.
From time to time you then need to update the submodule in your projects because the upstream maintainer has added a feature or version you want to have. This cannot be done by a simple “git pull” because git submodules are only pointers to a specific commit revision in another repo and therefore have a detached HEAD. This is necessary because you always want to have a specific revision when cloning your main repo. The revision the submodule repo had when you added it. Not any future commits which you might not know of.
So first of all you need to update your fork to get all upstream changes. This can be skipped if your submodule points directly to the 3rd-party repo !
# add the upstream repo URL
git remote add upstream https://github.com/puppetlabs/puppet-postgresql.git
git fetch upstream
git merge upstream/master
# resolve conflicts that might be there because you modified your fork
git add [conflict files]
git commit -m "Commit message."
git push origin master
git push --tags
Now your fork is up-to-date with the original code. We now need to update our submodule to our desired tag or revision:
git checkout master
git pull origin master
git pull --tags
# go to your desired tag or revision ID
git checkout 2.1.1
# now save the new submodule pointer
git add /path/to/submodule/
git commit -m "updated submodule to Tag 2.1.1"