Skip to content

Instantly share code, notes, and snippets.

@rakjin
Last active August 29, 2015 14:19
Show Gist options
  • Save rakjin/ea85bf9364598d2cee48 to your computer and use it in GitHub Desktop.
Save rakjin/ea85bf9364598d2cee48 to your computer and use it in GitHub Desktop.
force-push a dir to a git repo
#!/usr/bin/env sh
if [ -z "$1" ] || [ -z "$2" ]; then
echo " WARN: the remote repo will be RESET completely"
echo " usage:"
echo " `basename $0` <DIR_NAME> <REPO_URI>"
echo " `basename $0` files/ https://github.com/your/repo.git"
exit 1
fi
(
cd $1
if [ -e ".git" ]; then
echo "a git repo already exists in dir '$1'"
exit 1
fi
git init .
git add .
git commit -m 'rebase'
git remote add origin $2
git push -f origin master
rm -rf .git
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment