查找添加文件的提交(Find commit where file was added)

编程入门 行业动态 更新时间:2024-10-28 14:27:29
查找添加文件的提交(Find commit where file was added)

说我有一段时间以前提交的文件foo.js 我想简单地找到这个文件首次添加的提交。

在阅读答案和我自己的修补之后,这对我有用

git log --follow --diff-filter=A --find-renames=40% foo.js

Say I have a file foo.js that was committed some time ago. I would like to simply find the commit where this file was first added.

After reading the answers and my own tinkering, this works for me

git log --follow --diff-filter=A --find-renames=40% foo.js

                

最满意答案

这样比较简单,“纯git”的做法,无需管道:

git log --diff-filter=A -- foo.js

检查文档,您可以对删除,修改等进行相同的操作。

我有一个方便的别名,因为我总是忘记它:

git config --global alias.whatadded 'log --diff-filter=A'
 

这使得它简单如下:

git whatadded -- foo.js

Here's simpler, "pure git" way to do it, no pipeline needed:

git log --diff-filter=A -- foo.js

Check the docs, you can do the same thing for Deleted, Modified, etc.

https://git-scm.com/docs/git-log#Documentation/git-log.txt---diff-filterACDMRTUXB82308203

I have a handy alias for this because I always forget it:

git config --global alias.whatadded 'log --diff-filter=A'
 

This makes it as simple as:

git whatadded -- foo.js

更多推荐

本文发布于:2023-07-20 20:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1203725.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   Find   commit   file   added

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!