Skip to content

Instantly share code, notes, and snippets.

@KrustyHack
Created January 21, 2022 15:34
Show Gist options
  • Save KrustyHack/616ce5e1b4f2d9ce51b09e44269fcd6b to your computer and use it in GitHub Desktop.
Save KrustyHack/616ce5e1b4f2d9ce51b09e44269fcd6b to your computer and use it in GitHub Desktop.
Hard reset fork from upstream
#!/bin/bash
UPSTREAM="$1"
read -n 1 -p "/!\\ Keep in mind, that this makes your repo look exactly like upstream - If you have commits, they will be eaten ! /!\\ [y/n]" askinput
echo -e "\n"
if [ "${askinput}" == "y" ]; then
echo -e "Will force reset with upstream"
sleep 3
git remote add upstream "${UPSTREAM}"
git fetch upstream
git reset --hard upstream/master
else
echo -e "\nAborting"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment