Last active
August 29, 2015 14:19
-
-
Save rakjin/ea85bf9364598d2cee48 to your computer and use it in GitHub Desktop.
force-push a dir to a git repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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