1

I was trying to push the code and it says

remote: Push rejected.
remote:
remote: refs/heads/feature/ABCD-1234: 0d7591a7f67: commit message doesn't match regex: .*[A-Z]{2,}-[0-9]{1,}.*
remote:         Sample Push

What is the actual format and how do I push it? Do I need to revert back even if I do a new commit with

git commit -m "ABCD-1234 Sample Push"
Matt
  • 12,848
  • 2
  • 31
  • 53
Ansh Bajaj
  • 11
  • 1
  • 3
  • Amend the message? – matt Jun 06 '21 at 17:38
  • I am 3 commits ahead, I tried pushing after the third commit and got the error. Not sure about how amend command works – Ansh Bajaj Jun 06 '21 at 19:20
  • With amend I can only change the recent commit right? – Ansh Bajaj Jun 06 '21 at 19:27
  • 1
    You can edit the commit message of any commit. – matt Jun 06 '21 at 19:29
  • Does this answer your question? [How to modify existing, unpushed commit messages?](https://stackoverflow.com/questions/179123/how-to-modify-existing-unpushed-commit-messages) – matt Jun 06 '21 at 19:34
  • Fwiw those kind of pre-receive hooks are super annoying - why does _every commit_ in a feature need to reference an issue (instead of just the merge)? If it’s in your power, I suggest to rethink that, or ask for it to be removed. – AD7six Jun 06 '21 at 19:36
  • 1
    Does this answer your question? [How to modify a specified commit?](https://stackoverflow.com/questions/1186535/how-to-modify-a-specified-commit) – SwissCodeMen Jun 06 '21 at 20:29
  • Side note: `ABCD-1234 Sample Push` does match `.*[A-Z]{2,}-[0-9]{1,}.*`, but `Sample Push` alone does not. In any case `.*[A-Z]{2,}-[0-9]{1,}.*` is a poor regex *unless* whatever regex engine is running it does left-and-right-anchored searches, i.e., it's short for `^.*[A-Z]{2,}-[0-9]{1,}.*$`. It would be much better to just eliminate both `.*` expressions. – torek Jun 06 '21 at 22:06

1 Answers1

-1

In the output of git push, lines preceeded by remote: are the output of a hook installed on the remote side.

This error isn't a message coming from git itself, but rather indicate that the maintainers of the remote repo purposefully installed a script to force the compliance to some rule (it looks like they expect a message matching that regexp, and their intention is probably to have a link to a ticket in their issue tracker or some code to identify a feature).

So the question :

What is the actual format and how do I push it? Do I need to revert back even if I do a new commit with ...

can only be answered by the maintainers of that project.

Check the project's README, or see if they have some Contributing guidelines ; if you don't find your answer there, ask the maintainers directly.

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • I expect`commit message doesn't match regex: .*[A-Z]{2,}-[0-9]{1,}.*` can be taken at face value - along with `remote: Sample Push` (The failing commit message) and there isn’t a mystery as to what’s happening, I.e. it is not something which only the maintainers can answer. Good general advice all the same. – AD7six Jun 06 '21 at 21:13
  • @AD7six : granted, however we don't know what comes next : is the number checked a ticketing system ? does the hook apply to the head commit, or to all commits in the branch ? ... I thought it was important to highlight that, since this message *isn't* a message coming from git, asking on StackOverflow (a generalistic QA site) "what should I do with this repo ?" wil not yield a straight answer. – LeGEC Jun 07 '21 at 07:07