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 712457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:51:01+00:00 2026-05-14T04:51:01+00:00

I’d like to have a commit message cleanup that will not necessarily remove lines

  • 0

I’d like to have a commit message cleanup that will not necessarily remove lines beginning with a # in the message itself. The default --cleanup=strip removes all lines starting with a # character.

The reason being is unfortunately, the Trac engine’s wiki formatter uses hashes in the beginning of a code block to denote the syntax type. This creates difficulty when using the engine’s syntax in my commit messages.

Example:

Created demo of perl added to helloworld.pl

{{{
#!/usr/bin/perl
use strict;
# say hi to the user.
print "hello world\n";

}}}

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
#   (use "git reset HEAD^1 <file>..." to unstage)
#
#   added:   helloworld.pl
# and so on and so forth...

I would like the following result in the final logged commit message:

commit 1234567890123456789012345678901234567890
Author: Danny <...>
Date:   Wed Apr 7 13:34:29 2010 -0400

     Created demo of perl added to helloworld.pl

     {{{
     #!/usr/bin/perl
     use strict;
     # say hi to the user.
     print "hello world\n";

     }}}

I’d like to use a custom filter that removes all lines beginning with a hash from the bottom of the commit message upwards. Leaving the lines in the message I have added alone. Where or how can I specify this in git?

Note, creating a sed or perl script to perform the operation is not a problem, just knowing where to hook it into git is the question.

My apologies on the confusion of my question, I hadn’t realized how vague it was.

  • 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-14T04:51:01+00:00Added an answer on May 14, 2026 at 4:51 am

    I think you’ll want to use two things to accomplish this:

    • Specify the cleanup mode. git commit takes a --cleanup=<mode> option; you can use --cleanup=whitespace to prevent git from stripping any comments. The other choice you might want is verbatim, which (surprise) doesn’t touch the message. See the man page for the other choices, if you’re interested.

    • Use the commit-msg hook to edit the message in place. In case you haven’t used hooks before, the man page is called githooks, and they’re scripts placed in .git/hooks which are executed at the appropriate times. The commit-msg hook is executed with a single argument, the file containing the proposed commit message. It can edit the message in place, and if it returns failure (non-zero) the commit will be aborted. So, write your custom stripping script as .git/hooks/commit-msg, make sure it’s executable, and you’ll be set. Note that the hooks directory isn’t tracked; if you want to share this with others, a common method is to place it somewhere inside your repository, then symlink .git/hooks/commit-msg to it.

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

Sidebar

Ask A Question

Stats

  • Questions 417k
  • Answers 417k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Google Code Search finds many copies of des.h, where the… May 15, 2026 at 9:42 am
  • Editorial Team
    Editorial Team added an answer doublep / cluch answered the question :-) in the comment… May 15, 2026 at 9:42 am
  • Editorial Team
    Editorial Team added an answer This could mean that the project was targeted to different… May 15, 2026 at 9:42 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.