0

I have created a pre-push file and saved it into the .git/hooks folder. What seems to be going on is that the push is still making the call to the server even though I put in an echo statement and an exit 1 call. When I perform a git push call I can see the server message then my echo statement.

Shouldn't the push process stop immediately and not establish a connection to the remote server if the first line of the pre-push file is exit 1?

What am I missing here on this hook? The only thing that I would expect to see is my Hello there message and nothing else.

echo "Hello there" exit 1 

1 Answer 1

1

Okay, I don't have the complete answer but this is what I have figured out.

Despite getting the banner message from the remote server the pre-push does stop the process from pushing to the server upon exit 1. It is misleading only because I am seeing the banner message but it is working.

Something should be documented in the git docs on why a connection is established at all for a pre-push before the push has been given the go ahead.

Sign up to request clarification or add additional context in comments.

1 Comment

I agree that the documentation should be improved. It's quite necessary to establish the connection first, though, and a bit of thought will immediately show why: the pre-push hook gets not only the foreign Git's ref-name, it also gets the corresponding hash ID. The only entity that has that information—at least, correct information—is the foreign Git itself. So there must be a connection established, with data flowing, at this point.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.