Created
May 5, 2020 08:33
-
-
Save stefanofiorentino/d135f86741cdca960ea8a4edfba77f56 to your computer and use it in GitHub Desktop.
Git custom reset to hard reset all your repos to a specific tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ ${1} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] | |
then | |
for dir in $(find . -maxdepth 1 ! -path . -type d); | |
do | |
cd $dir | |
find . -type d -name '.git*' ! -path "*/poky-tmp/*" 2>/dev/null | \ | |
sed 's/\.git$//g' | \ | |
xargs -I '{}' sh -c 'readlink -e {};' | \ | |
uniq | \ | |
sort | \ | |
xargs -I '{}' sh -c 'cd {}; git reset --hard '${1}; | |
cd .. | |
done; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment