Created
August 17, 2017 11:40
-
-
Save omeranson/cc8fa1424ae6d1246e8fb4a13b86b642 to your computer and use it in GitHub Desktop.
Initialise a git repo for which push -f works out-of-the-box, and automatically resets to the updated commit.
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
#!/bin/bash | |
git init | |
git config receive.denyCurrentBranch ignore | |
touch .git/hooks/post-receive | |
chmod +x .git/hooks/post-receive | |
cat >> .git/hooks/post-receive << EOF | |
#!/bin/bash | |
test "\${PWD%/.git}" != "\$PWD" && cd .. | |
unset GIT_DIR GIT_WORK_TREE | |
git reset --hard | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment