I have a git repo and I just pushed it to a server. Then I setup a post-receive hook on the server. I want to check it works. I have to commit again just to see if it works? I would really like to just force a push while I'm trying to get this set up rather than keep making commits that have no real value. Its not working, and I just don't get it.
$ git push --force origin master
Everything up-to-date
You need to push an older commit to achieve this. For example, you could push the commit right before the current HEAD using this comment:
git push --force origin HEAD^:master
After this you can push the HEAD commit again:
git push origin master
However, instead of pushing all the time consider calling the hook manually. That's usually easier - but don't forget to test with an actual push when you think everything works just to be sure.
There's a little dirty trick you can use:
git stash save && git push --force origin "stash@{0}:master" && git stash pop
This does 3 things:
This will effectively push all files to the remote without creating a local commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With