Skip to content

Commit 86f4128

Browse files
committed
Trivial helper script to git clean submodules
Since we added the use of git submodules recently, this trivial script has been helpful to me to "git clean" not only the top-level Open MPI repo, but also all the included submodules, too. NOTE: this script does the (harsh) "git clean -dfx" command, which deletes everything that git does not know about. Use with care! Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
1 parent a7ed13d commit 86f4128

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

contrib/git-clean.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# Copyright (c) 2020 Cisco Systems, Inc. All rights reserved.
3+
# $COPYRIGHT$
4+
#
5+
# Additional copyrights may follow
6+
#
7+
# $HEADER$
8+
#
9+
# Trivial helper script to git clean a tree and all of its submodules.
10+
11+
set -euo pipefail
12+
13+
# Top git dir
14+
root=$(git rev-parse --show-toplevel)
15+
cd $root
16+
17+
# Clean the top-level dir
18+
echo "=== Cleaning top-level git directory"
19+
git clean -dfx .
20+
21+
submodule_dirs=$(git submodule status | awk '{print $2}')
22+
if test -z "$submodule_dirs"; then
23+
echo "No submodules to clean"
24+
exit 0
25+
fi
26+
27+
for dir in $submodule_dirs; do
28+
echo "=== Cleaning submodule: $dir"
29+
cd $dir
30+
git clean -dfx .
31+
cd $root
32+
done

0 commit comments

Comments
 (0)