Skip to content

Instantly share code, notes, and snippets.

@MiffOttah
Last active March 4, 2020 16:38
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 MiffOttah/8576c3f617a61aebf4f8ba90079bc365 to your computer and use it in GitHub Desktop.
Save MiffOttah/8576c3f617a61aebf4f8ba90079bc365 to your computer and use it in GitHub Desktop.
#!/bin/bash
# git-gud - deletes all local data and refetches the entire repo from the origin
TOPLEVEL=`git rev-parse --show-toplevel`
if [ -z "$TOPLEVEL" ]; then
echo 'Not in a git repository.'
exit 1
fi
ORIGIN=`git remote show origin`
if [ -z "$ORIGIN" ]; then
echo 'Git repository doesn't have a remote origin.'
exit 2
fi
rm -rf $TOPLEVEL
git clone $ORIGIN $TOPLEVEL
#!/bin/bash
# git-rekt - forces your data into the remote master
TOPLEVEL=`git rev-parse --show-toplevel`
if [ -z "$TOPLEVEL" ]; then
echo 'Not in a git repository.'
exit 1
fi
ORIGIN=`git remote show origin`
if [ -z "$ORIGIN" ]; then
echo 'Git repository doesn't have a remote origin.'
exit 2
fi
cd $TOPLEVEL
rm -rf $TOPLEVEL/.git
git clone --bare $ORIGIN $TOPLEVEL/.git
git add .
git commit -m "git-rekt, scrub!"
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment