从git diff命令结果中获取JSON内容。

huangapple go评论73阅读模式
英文:

Fetching json content from a git diff command result

问题

Sure, here's the translation of the content you provided:

  1. Git diff tag1.2 tag1.5
  2. 上述命令的输出为

**标签
一些字符
@@262728
{
'Code-version':'1.5',
'changes':[
'code-repo':'2.1']
}
**标签
一些字符
@@262728
{
'Code-version':'1.4',
'changes':[
'code-repo':'2.0']
}
**标签
一些字符
@@262728
{
'Code-version':'1.3',
'changes':[
'code-repo':'1.9']
}

  1. 我需要仅显示最新的 JSON 内容,如下所示,不包括其他不需要的内容

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

英文:
  1. Git diff tag1.2 tag1.5

Output for the above command is

  1. **Tag
  2. Some character
  3. @@262728
  4. {
  5. 'Code-version':'1.5',
  6. 'changes':[
  7. 'code-repo':'2.1']
  8. }
  9. **Tag
  10. Some character
  11. @@262728
  12. {
  13. 'Code-version':'1.4',
  14. 'changes':[
  15. 'code-repo':'2.0']
  16. }
  17. **Tag
  18. Some character
  19. @@262728
  20. {
  21. 'Code-version':'1.3',
  22. 'changes':[
  23. 'code-repo':'1.9']
  24. }

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

  1. {
  2. 'Code-version':'1.5'
  3. 'changes':[
  4. 'code-repo':'2.1']
  5. }

答案1

得分: 1

如果您对特定标签(或提交)下文件的内容感兴趣,您可以使用 git show 命令:

  1. git show 标签名:路径/至/文件

git diff 显示文件的两个不同版本之间的差异,但您只关心文件的一个特定版本。

英文:

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

  1. 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.

huangapple
  • 本文由 发表于 2023年5月17日 17:18:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76270459.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定