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

  • Home
  • SEARCH
  • 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 8847707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:15:16+00:00 2026-06-14T12:15:16+00:00

When I run the command git cherry origin/Server_Dev in my git repository, I get

  • 0

When I run the command

git cherry origin/Server_Dev

in my git repository, I get a list of commits of the form

+ 95b117c39869a810595f1e169c64e728d2d7443d
+ e126f1b996ecf1d2a8cf744c74daa92cce338123
+ 869169a6cb0bbe8f1922838798580a1e74ec3884
+ 667819b617c88bd886dc2001f612b5c7a4d396c3
+ fd41328a84b0a127affa6fe4328c93e933de378c
+ cfe1807e5d4acc6b5e75f4463dadb3b1c957376f

This is a good thing.

I now want to execute this command from within a bash script and capture the output into an array using the following code:

commit_hashes=(`git cherry origin/Dev`)
echo ${commit_hashes[@]}

which yields the following output:

+ 95b117c39869a810595f1e169c64e728d2d7443d + e126f1b996ecf1d2a8cf744c74daa92cce338123 + 869169a6cb0bbe8f1922838798580a1e74ec3884 + 667819b617c88bd886dc2001f612b5c7a4d396c3 + fd41328a84b0a127affa6fe432
8c93e933de378c + cfe1807e5d4acc6b5e75f4463dadb3b1c957376f

This is not a good thing

My list of commits is being returned as a string which I must first break up before I can use it. After some searching I found out that if I add IFS="" to my script before the capturing of the data, my problems would be solved.

So I edited my code to read

IFS=""
commit_hashes=(`git cherry origin/Dev`)
echo ${commit_hashes[@]}

which output

+ 95b117c39869a810595f1e169c64e728d2d7443d
+ e126f1b996ecf1d2a8cf744c74daa92cce338123
+ 869169a6cb0bbe8f1922838798580a1e74ec3884
+ 667819b617c88bd886dc2001f612b5c7a4d396c3
+ fd41328a84b0a127affa6fe4328c93e933de378c
+ cfe1807e5d4acc6b5e75f4463dadb3b1c957376f

This completely ended my sense of reality.

I like to know why things are doing what they’re doing, so after some more searching I found out that this is called the Internal Field Separator and it is used on Unix systems by command interpretors to figure where to break patterns up into tokens.

This I understand.

What I don’t understand is

  1. Why setting this variable to an empty string allowed it to handle my array data in a sane manner.
  2. Why I had to set it so in the first place, instead of the interpretor realising it was dealing with array data and handling it appropriately.
  3. What effect setting the Internal Field Separator to an empty string will have in the grand scheme of things, since by default it contains the characters for a space, a tab and a newline.

Some help in getting my head around these three points would be appreciated.

  • 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-14T12:15:17+00:00Added an answer on June 14, 2026 at 12:15 pm

    See man bash/Arrays. Everything is fine with your array. When you do

    echo ${commit_hashes[@]}
    

    echo shows all array elements on one line, as it is told to. When you say

    for i in `seq 10`; do
        echo ${commit_hashes[$i]}
    done
    

    you will see that just one entry per line is shown.

    When you set IFS= to an empty string however, the result of git cherry isn’t broken up into multiple values. The whole string including the newlines is assigned to the first array element. If you

    echo ${commit_hashes[0]}
    

    in your second case, you will see, that echo shows all output lines.

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

Sidebar

Related Questions

Everybody, I get an error when I run this command: git push heroku master.
I have run this command with root: [root@localhost git-shell-commands]# ssh git@192.168.1.12 git@192.168.1.12's password: Last
I'd like to be able to run a command that opens up a git
I run command: sudo apt-get install phpmyadmin to install phpMyAdmin. Then I enter address:
I run this command : select * from LIST where JCODE = 8 and
I am using windows git bash, when i run the command git push beanstalk
I'm trying to run the command git branch | grep \* like so: require('child_process').exec('git
I have a git command that I run to display my logs. It mostly
When I run the command: git log --after=21/9/2012 It seems to have a hidden
Currently I want to run a batch file that fires the command git log

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.