Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试git diff使用 ruby gem grit 查找当前已删除的所有代码行(在未暂存的更改中),即我想查看所有涉及删除的未暂存更改。这相当于git diff -U0 | grep ^-[^-]在 shell 中做。
git diff
git diff -U0 | grep ^-[^-]
到目前为止,我只能弄清楚如何获取两次提交之间的差异,或者获取已更改文件的名称。
尝试如下:
diff = @repo.git.diff({:U0 => true}).split( "\n" ).grep( /^-[^-]/ ).join( "\n" )