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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:08:52+00:00 2026-06-16T05:08:52+00:00

I want to format git-log match in a convenient way. The output of git-log

  • 0

I want to format git-log match in a convenient way.
The output of git-log command is given:

commit 11ae9c97409fb349e2bfa50ed65bd23ec6dbca70
Author: Fabien Potencier <fabien.potencier@gmail.com>
Date:   Wed Jul 11 19:51:30 2012 +0200

    updated VERSION for 2.0.16

commit 6e14d67cb23439d6700f494e29e809811edeeade
Author: Fabien Potencier <fabien.potencier@gmail.com>
Date:   Wed Jul 11 19:50:55 2012 +0200

    update CONTRIBUTORS for 2.0.16

commit 0341492ed566fca8df556573b9664f691c5dff3d
Author: Fabien Potencier <fabien.potencier@gmail.com>
Date:   Wed Jul 11 19:48:12 2012 +0200

    updated CHANGELOG for 2.0.16

commit b18f6f557b5db1e2e6d2c2c0494e0564b91f438d
Author: Fabien Potencier <fabien.potencier@gmail.com>
Date:   Tue Jul 10 15:28:02 2012 +0200

    [Console] fixed wrong phpdoc (closes #4394)

I want to format as given below:

Fabien Potencier, Wed Jul 11 19:51:30 2012 +0200

    updated VERSION for 2.0.16

Fabien Potencier, Wed Jul 11 19:50:55 2012 +0200

    update CONTRIBUTORS for 2.0.16

Fabien Potencier, Wed Jul 11 19:48:12 2012 +0200

    updated CHANGELOG for 2.0.16

Fabien Potencier, Tue Jul 10 15:28:02 2012 +0200

    [Console] fixed wrong phpdoc (closes #4394)

for that I wrote a PHP script as given below.

<?php

$r = shell_exec('git log');

$p = '/commit (.{2})(.{4})(.{6})/';// THIS SHOULD CHANGE!

preg_match_all($p, $r, $match);

unset($match[0]);

$output = array();

foreach($match as $k1=> $v1)

    foreach($v1 as $k2=>$v2)

          @$output[$k2] .= $v2 . ($k1==1 ? ',' : PHP_EOL);

echo implode('', $output);

I don’t have any idea about the pattern I should be used here. Please help me.

  • 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-06-16T05:08:53+00:00Added an answer on June 16, 2026 at 5:08 am

    Something along these lines should do the trick:

    /Author:\s*(?<name>.+)\s+Date:\s*(?<date>.+)\s+(?<message>(?:(?!commit .{40}).)+)/i
    

    Three backreferences set, one for each set of data you want.

    Print the $match-array if you need help understanding the saved data.

    Demo+explanation: http://regex101.com/r/cA0lD3

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

Sidebar

Related Questions

I want to send .patch files that were generated by the git format-patch command
I want gitweb to output the same diff format as git diff --color-words .
I want to take the output of a git log and use it as
I want to format my numbers throughout the application in a consistent way, no
How can I show a git log output with (at least) this information: *
I want to use git log to get a list of changes starting with
I want a way to list all git authors that Is only since a
I want a list of files affected by a certain commit in git. Through
I want to use the new git commit --fixup feature. Unfortunately, it was added
I want to use a git hook to force commit messages to comply with

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.