Friday, August 21, 2009
A couple of hooks to make life easy with git submodules
While using git at work for the last few weeks, I noticed a couple of issues with the usage of git-submodules.
Hope someone will find them useful.
- Submodules updated in commits when not intended to be -- more or less due to over-enthusiastic usage of
git commit -a
. - Failure to run git-submodule update after a git-merge (git-pull) or git-checkout.
http://github.com/chaitanyagupta/gitutils/treeThree git-hooks can be found in the submodule-hooks/ directory:
pre-commit
, post-merge
and post-checkout
(post-merge-checkout
provides the latter two).pre-commit
checks if any submodules have been updated in the index and are about to be committed. If so, it asks user for confirmation to go ahead with the commit.post-merge-checkout
checks if any submodules have been modified in the working tree (i.e. their git-status is "modified" under "Changed but not updated") after a branch checkout or merge. If that is the case, it asks the user if they want to run git submodule update
.Hope someone will find them useful.
Labels: git
Subscribe to Posts [Atom]