I normally use something like the following to test my changes, and if they are ok, push them to the remote repository:
mvn install && git push
Works great except for that stupid user that has written beautiful code, but forgot to commit it /facepalm/
Is there a way to make git push fail when there are uncommitted changes? Or maybe a separate command that checks for uncommitted changes, so I get something like this:
mvn install && git --clean-only push
or
mvn install && git is-clean && git push
Hence, your uncommitted changes won't be pushed to remote in any scenario unless you commit those and then do git push .
So commiting changes without pushing allow the save-load behaviour done locally during development. Once you are happy with your work, you then commit AND push.
The upstream Git repository will be oblivious to your attempted push, and no change will occur upstream. Unfortunately however, as it doesn't do anything with the half-pushed files, it doesn't store it and then expect a continuation of the push later on either.
You could probably use mvn install && git diff --quiet --cached && git push
. This checks for uncommitted changes. If you'd like to check for unstaged changes, use git diff --quiet
instead (or both).
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