There is a handy thing on a githab: write a comment to the commit, indicate the issue number - and they are connected after pushing. For example:

Added conversion logging. #50

Another thing is that I sometimes forget to affix this number, I would like to fasten some kind of check, rather on the server side, but it can be done locally.

The question is - are there any ready-made solutions?

If not, how can this be done?

    2 answers 2

    (googling using githukh), but I’ll answer about the disadvantages of the server commute message approach

    on the server side - not necessary. if you force coders to add mandatory messages to a commit, sooner or later someone will make 120 commits locally, then it turns out that one of the commits (say, the first one) is commented incorrectly.

    zakomitit impossible. will have to call / write / put a ticket to you.

    You will be advised to rebase. rebase does not work, because someone above the tree has changed the directory structure.

    it's a waste of time. if you want to enforss comments, do it on the client so that the person who needs to push something up _important_and_ Urgent_ (this happens in production) can do git commit --no-verify

    PS server githuk, which does not forbid to push, but he puts down the number of the patch or other information useful - it is quite ok.

    • Thanks, in general, I figured out at least where to look. If you google exactly hooks, then quickly find a solution. - Monk

    Visual Studio ignores hooks, you'll have to commit manually.

    In the folder. .git\hooks you need to add a text file commit-msg

    I had this simple (skopipastil from here ):

     #!/usr/bin/env bash # regex to validate in commit msg commit_regex='(#[0-9]+|merge)' error_msg="Aborting commit. Your commit message is missing either a Issue ('#123') or 'Merge'" if ! grep -iqE "$commit_regex" "$1"; then echo "$error_msg" >&2 exit 1 fi 

    On Linux, you will still need to allow execution:

     chmod +x commit-msg 
    • in the sense of "ignore hooks"? - strangeqargo
    • Look, well, three years have passed, haven't they fixed it? libgit2 seems to be alive and vs is also developing - strangeqargo
    • one
      @strangeqargo Well, the libgit2 bug is closed without a real fix, and the fresh studio still ignores it. Apparently yes, they did not fix it. - Monk
    • a, read. this is not so much a bug as “not our feature”, rather the studio should handle it. interesting to check will be with phpstorm / clion - strangeqargo