首页 \ 问答 \ 当比较git repo中的2个文件时,这个INDEX值是什么意思?(What does this INDEX value mean when comparing 2 files out of the git repo?)

当比较git repo中的2个文件时,这个INDEX值是什么意思?(What does this INDEX value mean when comparing 2 files out of the git repo?)

git diff --no-index可用于比较2个任意文件。

我试过如下:

$ git diff --no-index -- /d/a.txt /d/b.txt
diff --git a/D:/a.txt b/D:/b.txt
index 7c4a013..01f02e3 100644
--- a/D:/a.txt
+++ b/D:/b.txt
@@ -1 +1 @@
-aaa
\ No newline at end of file
+bbb
\ No newline at end of file

我想因为我正在比较git repo中的2个文件,所以应该与INDEX无关。 但index 7c4a013..01f02e3 100644是什么意思?


git diff --no-index can be used to compare 2 arbitrary files.

I tried as below:

$ git diff --no-index -- /d/a.txt /d/b.txt
diff --git a/D:/a.txt b/D:/b.txt
index 7c4a013..01f02e3 100644
--- a/D:/a.txt
+++ b/D:/b.txt
@@ -1 +1 @@
-aaa
\ No newline at end of file
+bbb
\ No newline at end of file

I think since I am comparing 2 files out of the git repo, there should be nothing to do with the INDEX. But what does the index 7c4a013..01f02e3 100644 mean?


原文:https://stackoverflow.com/questions/37994800
更新时间:2022-05-18 12:05

最满意答案

Get-Content返回一个字符串数组,并且数组有自己的.IndexOf()方法,用于查找数组中的项。 "192"不是数组中的完整字符串,因此找不到它。

您希望Get-Content -Raw返回单个字符串,或者更可能是Get-Content ... | ForEach-Object { $_.IndexOf("192") } Get-Content ... | ForEach-Object { $_.IndexOf("192") }测试一行。

或类似select-string来测试文件中的任何行。


Get-Content returns an array of strings, and arrays have their own .IndexOf() method which looks for items in the array. "192" is not a complete string in the array, so it's not found.

You want either Get-Content -Raw to return a single string, or more likely Get-Content ... | ForEach-Object { $_.IndexOf("192") } to test each line one at a time.

Or something like select-string to test any line in the file.

相关问答

更多
  • 模式匹配innerHTML在IE中尤其是一个问题,通常是一个坏主意。 IE通常不会返回与页面中最初相同的HTML。 它经常重新引用或删除引号,更改属性的顺序,更改大小写等等...... IE显然正在重构HTML而不是回复页面中最初的内容。 因此,您无法在IE中可靠地模式匹配innerHTML。 您可以匹配一些特定的东西(标签的开头),但您不能指望属性位于特定位置或具有特定格式。 如果您在IE中使用console.log(obj.innerHTML) ,您可能会看到我在说什么。 它看起来会有所不同。 更强大的 ...
  • Array.indexOf()使用严格的等式( === )来查找元素。 mapping的元素是数组,碰巧具有相同元素的两个不同的数组不是=== 。 我怀疑process_mapping_list()返回的是一个看起来像mapping元素之一的数组,但不是元素本身(就像你的小提琴一样)。 您可能需要编写自己的查找函数,该函数使用自定义相等性测试。 对于这样的测试,请看一下这个帖子 。 根据您定位的环境,您可以使用findIndex()而不是indexOf() 。 该功能允许您提供自己的测试功能。 Array. ...
  • 你的标题提到val()但你并没有真正使用它。 formMain是一个jquery对象,没有value ,你应该使用val() 。 var formMain = $('#MainForm :input[name="Search"]'); if (formMain.val().indexOf('word') >= 0) { alert('HAS THIS WORD IN IT!'); } 还要注意, formMain是一个误导性的变量名称,因为它不是主要的形式,而是一个包含搜索输入的jquery对象 ...
  • indexOf(value)在不匹配时返回-1在匹配时返回0的索引。 在你的情况下,你应该将结果与0比较,而不是1。 请注意,如果要测试节点是否具有某个特定的类名,则这不是一个好习惯。 更好的方法是使用现代浏览器中可用的DOM API node.classList.contains() 。 或者使用正则表达式/\bblah\b/.test(node.className)来避免blah是另一个类名的子字符串,例如not-blah 。 另一种方法是使用mootools,它将node.hasClass()提供给H ...
  • 您必须使用一些实际值来调用Add-Numbers: function Add-Numbers($a,$b) { $a + $b } Add-Numbers 1 2 将返回3 。 如果要执行ps1并将值传递给它,则在第一行中写入Param块: param($a,$b) function Add-Numbers($a,$b) { $a + $b } Add-Numbers $a $b 现在,您可以使用两个值调用脚本。 注意:您将调用ps1文件,而不是您定义的函数的名称(整个脚本被执行)。 ...
  • Get-Content返回一个字符串数组,并且数组有自己的.IndexOf()方法,用于查找数组中的项。 "192"不是数组中的完整字符串,因此找不到它。 您希望Get-Content -Raw返回单个字符串,或者更可能是Get-Content ... | ForEach-Object { $_.IndexOf("192") } Get-Content ... | ForEach-Object { $_.IndexOf("192") }测试一行。 或类似select-string来测试文件中的任何行。 Ge ...
  • 根据文档 $Catalog.Applications是一个Microsoft.BizTalk.ExplorerOM.Application对象的数组,而您需要一个具有这些对象的名称字符串的数组。 尝试这样的事情: if ( ($Catalog.Applications | select -Expand Name) -contains $AppName ) { ... Write-EventLog ... } else { ... Invoke-Expression $Addapp } Ac ...
  • 试试FindByValue() cboCategory.SelectedIndex = cboCategory.Items.IndexOf(cboCategory.Items.FindByValue(lstItem.Value)); Try with FindByValue() cboCategory.SelectedIndex = cboCategory.Items.IndexOf(cboCategory.Items.FindByValue(lstItem.Value));
  • 你的代码没有用,因为当你说: res.indexOf("f") != -1 这意味着:“我找到了一个f”,但你把它当作“我没找到f”的意思。 在你的情况下,如果你找到'f',你想要返回false,但你返回true。 翻转您的真假案例: if (res.indexOf("f") != -1) { return false; } else { return true; } 你的for循环也是错误的,因为x从0开始,所以你需要转到
  • Twitter API将双引号返回为" 。 例如,请查看此查询的响应: http : //search.twitter.com/search.json ?q = foo 。 因此,您需要使用tweet.text.indexOf('"')代替。 The Twitter API returns double-quotes as ". As an example, check out the response for this query: http://search.twitter ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。