aboutsummaryrefslogtreecommitdiff
path: root/git/git-checkout-clean.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git/git-checkout-clean.sh')
-rwxr-xr-xgit/git-checkout-clean.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/git/git-checkout-clean.sh b/git/git-checkout-clean.sh
new file mode 100755
index 0000000..927b6f8
--- /dev/null
+++ b/git/git-checkout-clean.sh
@@ -0,0 +1,19 @@
+#!/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