From ad9e7cd5117c965222aae708f660e56d537914fc Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 6 Oct 2025 00:48:48 +0300 Subject: imported all of my Github gists from https://gist.github.com/rhaberkorn --- git/git-checkout-clean.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 git/git-checkout-clean.sh (limited to 'git/git-checkout-clean.sh') 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 -- cgit v1.2.3