gitgithubdiffgithub-cli

Fetching json content from a git diff command result


Git diff tag1.2 tag1.5

Output for the above command is

**Tag
Some character
@@262728
{
'Code-version':'1.5',
'changes':[
'code-repo':'2.1']
}
**Tag
Some character
@@262728
{
'Code-version':'1.4',
'changes':[
'code-repo':'2.0']
}
**Tag
Some character
@@262728
{
'Code-version':'1.3',
'changes':[
'code-repo':'1.9']
}

I need to display only the latest json content like below excluding other unwanted stuffs

{
'Code-version':'1.5'
'changes':[
'code-repo':'2.1']
}

Solution

  • If you are interested in the content of a file at a specific tag (or commit), you can use git show:

    git show tagname:path/to/file
    

    git diff shows the difference between two revisions of a file, but you are only interested in one specific version of the file.