Skip to content

Instantly share code, notes, and snippets.

@stefanofiorentino
Created May 5, 2020 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanofiorentino/d135f86741cdca960ea8a4edfba77f56 to your computer and use it in GitHub Desktop.
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
#!/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