Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4569256
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:11:34+00:00 2026-05-21T19:11:34+00:00

So my branch is named after bugtracker ticket number, something like issue-1234, and we

  • 0

So my branch is named after bugtracker ticket number, something like “issue-1234”, and we have a convention to always write down ticket number in commit message. I’m wondering if it’s possible to append the ticket number in commit message automatically when I’m working on an issue-* branch without me explicitly typing it.

I looked at git commit hooks, namely pre-commit, prepare-message, and post-commit, and none of them seem to be able to do what I wanted. Post-commit hook comes close, but you cannot modify the message that’s committed with -m.

To reiterate, I’m wondering if this is possible:

On branch: issue-1234

git commit -a -m"fixed this pesky issue"

After the commit, in git log, it shows the message as:

fixed this pesky issue. ticket number: #1234
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:11:34+00:00Added an answer on May 21, 2026 at 7:11 pm

    You missed a hook. The one you want is commit-msg:

    This hook is invoked by git commit, and can be bypassed with –no-verify option. It takes a single parameter, the name of the file that holds the proposed commit log message. Exiting with non-zero status causes the git commit to abort.

    So for example:

    #!/bin/sh
    
    ticket=$(git symbolic-ref HEAD | awk -F- '/^issue-/ {print $2}')
    if [ -n "$ticket" ]; then
        echo "ticket #$ticket" >> $1
    fi
    

    That’s a very naive parsing of your branch name, and it’s simply appended to the commit message on its own line. Modify it if that’s not good enough for you.

    Of course, I’d actually recommend doing this in prepare-commit-msg, and committing with git commit (without -m). It’s very, very rare that you can actually write sufficient information in a single-line commit message. Further, that will let you see the message before the commit is made, in case your hook doesn’t do quite what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big named branch with a lot of changes. Some of these
How do I update to the head of a named branch (regardless if it
If you've named a branch in CVS incorrectly, or the name originally chosen becomes
Problem statement - [Business] 1---* [Branch] A business must have one or more branch(es).
I have a branch in an SVN tree which contains the source to a
rails -> 2.3.8 ruby -> 1.8.7 After auto_complete plugin installstion i still have undefined
I would like to combine many commits in to one. I have followed the
After I have re-deployed my app to Heroku, it displays the old public/index.html. What
I have an INSERT statement that looks like this: INSERT INTO officer (officer_number, name,
I have a git repository. I want to create a branch for release snapshots.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.