#!/bin/sh # This script performs a checkout with same arguments as `git checkout` # but makes sure that submodules are initialized in exactly the way # described in the branch/tag. # This is useful to avoid having to cleanup the tree after checkout # to prevent files interfering with Eclispe and updating submodules # manually. # # NOTE: This does not prevent other untracked files from intefering # with Eclipse. # # WARNING: THIS WILL DISCARD ALL LOCAL MODIFICATIONS TO YOUR SUBMODULES. # MAKE SURE TO COMMIT/PUSH OR SAVE THEM BEFORE YOU EXECUTE THIS SCRIPT. set -e git submodule foreach 'rm -rf $toplevel/$path' git checkout "$@" git submodule sync git submodule update --init