Hana Lihovac
Hana Lihovac

Reputation: 26

How to bypass the pre-receive hook for a single commit?

I want to push the code in java script to the remote repo on git, the repo contains per-recived hook that is scanning the code and I get the error that my code contains private key, after looking into it my code does not contain private key or any secret information. It only contains a word rsa-key that pre-receive hook sees as a threat and it does no allow me to push my code. Is there any solution how to skip scanning some java script files without using .gitignote, or changing anything in the code because that is not possible right now.

I tried:

git push --no-verify
# got the same error 
remote: [WARNING] You are trying to commit a password, token, private key or confidential information which is not allowed in our **** Git

Upvotes: 1

Views: 1853

Answers (1)

LeGEC
LeGEC

Reputation: 52186

A pre-receive hook is set on the server, and cannot be bypassed using only git options from the client side.


You may report an issue to the maintainers of the project, and have them update their hook so that your false positive doesn't get rejected anymore,
or perhaps find a workaround in your code to skip the check (e.g: turn const tag = "rsa-key" into const tag = "rsa-"+"key" or some similar bad hack ...)

You may also ask the maintainers (or, hopefully, read the repo's documentation ...) for a way to give extra instructions to this pre-receive hook -- for example: a special keyword in the commit message (skip-key-check ?) or a comment next to the incriminated line in your code (//pre-receive-secret:skip ?)

Upvotes: 1

Related Questions