There is one thing I want: the latest bits of the remote master. This is equally true for the for the sub-modules. I'm not interested in any other branch or history. Any change made locally irrespective whether these changes are tracked or not should be blindly ditched.
So, here is my shot on this, formulated as part of a Makefile. It is quite slow (lots of/large files) and it fails some times. Please let me know how to improve it:
pull: $(LOCAL_REPO)
cd $(LOCAL_REPO) && git submodule foreach git fetch origin master
cd $(LOCAL_REPO) && git submodule foreach git reset --hard FETCH_HEAD
cd $(LOCAL_REPO) && git submodule foreach git clean -fdx
cd $(LOCAL_REPO) && git submodule foreach git pull --rebase --allow-unrelated-histories origin master --depth 1
cd $(LOCAL_REPO) && git fetch origin master
cd $(LOCAL_REPO) && git reset --hard FETCH_HEAD
cd $(LOCAL_REPO) && git clean -dfx
cd $(LOCAL_REPO) && git pull --rebase --allow-unrelated-histories origin master --depth 1
$(LOCAL_REPO):
mkdir -p $(LOCAL_REPO)
cd $(LOCAL_REPO) && git init
cd $(LOCAL_REPO) && git remote add origin $(PRIVATE_GITHUB_GIT)
cd $(LOCAL_REPO) && git pull origin master --depth 1
cd $(LOCAL_REPO) && git submodule init $(SUBMOD1) $(SUBMOD2) $(SUBMOD3)
cd $(LOCAL_REPO) && git submodule update --remote --merge --depth 1