Skip to content

Instantly share code, notes, and snippets.

@stefanofiorentino
Last active May 6, 2020 14:31
Show Gist options
  • Save stefanofiorentino/3993cdaa213c782e4affa2d99c6c5be5 to your computer and use it in GitHub Desktop.
Save stefanofiorentino/3993cdaa213c782e4affa2d99c6c5be5 to your computer and use it in GitHub Desktop.
git hard reset from repo.log from git-repos
#!/bin/bash
PREVPWD=${PWD}
echo "Current Directory -> " ${PREVPWD}
while IFS= read -r line
do
command=$(echo "$line" | awk 'BEGIN { FS = " " } ; {print "cd \""$2"\" && git reset --hard "$8}')
if eval "${command}"; then
echo "${command}"
else
echo "ERROR: ${command}"
cd ${PREVPWD}
return 1
fi
done < "$@"
echo "Going back to -> " ${PREVPWD}
cd ${PREVPWD}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment