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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:02:46+00:00 2026-06-04T13:02:46+00:00

I am trying to export several commits (those that contain a specific ticket number

  • 0

I am trying to export several commits (those that contain a specific ticket number 1234 in the commit message) to patch files.

EDIT The working script is on https://github.com/amenk/SelfScripts/blob/master/git-extract-patches

This is what I have

#!/bin/bash -x
commits=`git log --pretty=oneline | grep "#1234" | cut -f1 -d" "`
no=1;
for COMMIT in $commits
do
    git format-patch -1 $COMMIT --start-number=$no
    no=$(($no+1))
done

But for some reason executing of git format-patch fails:

$ ./getpatches.sh 
++ git log --pretty=oneline
++ grep '#6809'
++ cut -f1 '-d '
+ commits='da591d66f05513488ee06857edc9d24a046c179d
4fd781da9cc503b961f8e4c42bbb136d9e3c1806
3a9311f5507f91f830b44673c57f672e7aabaac0'
+ no=1
+ for COMMIT in '$commits'
+ git format-patch -1 'da591d66f05513488ee06857edc9d24a046c179d' --start-number=1
fatal: ambiguous argument 'da591d66f05513488ee06857edc9d24a046c179d': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

When I call git format-patch -1 'da591d66f05513488ee06857edc9d24a046c179d' --start-number=1 manually, everything is fine.

EDIT:

I think it is something with the quotes. If I add a git log | grep $COMMIT into the loop, I get the following error:

+ grep '992ab41d3539539bd609209beed33a9de2f4277a'
grep: Unmatched [ or [^

Another interseting effect is, if I hard-code grep '992ab41d3539539bd609209beed33a9de2f4277a' in the for loop, the command output (because of the -x option for bash is without the quotes and it works.

 + grep 992ab41d3539539bd609209beed33a9de2f4277a

Where are these quotes coming from and how do I get rid of them?

  • 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-04T13:02:48+00:00Added an answer on June 4, 2026 at 1:02 pm

    My git was implicitly using the --color option so the $COMMIT string contained some color codes. So this messed up the parsing. Interesting, that also the color was contained in my error messages.

    But you do not see this in the terminal (it’s just colorful), and also not after pasting to stack overflow.

    The solution is:

    commits=`git log --no-color --pretty=oneline | grep "#1234" | cut -f1 -d" "`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to export a list of changed files from two commits with git,
I'm trying to export a profile from WAS 6.1 so that I can give
I'm trying to export the data that is shown in plot(yi) using wavwrite. When
I have some constants in JavaScript that I'd like to reuse in several files
I am trying to export transparent PNG files using this class: com.adobe.images.PNGEncoder; var pngSource:BitmapData
i am trying to export the elements in gridview to excel spreadsheet. that grid
I am trying to export data from my MySQL database to multiple CSV files
I am trying to join together several audio files into one mp4/m4a file containing
I trying to export an HTML table named Table that is dynamically binded to
I am currently developing an application that processes several files, containing around 75,000 records

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.