简体   繁体   English

如何查找本地Git工作目录中的文件删除时间?

[英]How can I find when a file was deleted in a local Git working directory?

I was recently making some changes to a local Git repo, and I saw that a bunch of files had been deleted from the local repository. 最近,我对本地Git存储库进行了一些更改,我发现一堆文件已从本地存储库中删除。 I hadn't committed these changes, so the files weren't actually deleted on the remote Git repo, but I'm still curious as to when these files were deleted on my local machine (as I don't recall deleting anything, and I would definitely never delete these files). 我尚未提交这些更改,因此实际上并没有在远程Git存储库上删除这些文件,但是我仍然对何时在本地计算机上删除这些文件感到好奇(因为我不记得删除任何内容,并且我绝对不会删除这些文件)。

I basically just typed git status , and saw that a bunch of files in my local repo had been deleted: 我基本上只是输入git status ,然后发现本地存储库中的一堆文件已被删除:

modified:   .DS_Store
deleted:    _posts/2019-06-06-First-Post.markdown
deleted:    _posts/2019-06-07-Probduct-Update.markdown
deleted:    _posts/2019-06-28-Project-Update.markdown
deleted:    about.md
modified:   assets/.DS_Store
deleted:    assets/graph.png

I don't know how or why these files got deleted, that is what I'm interested in figuring out. 我不知道如何或为什么删除这些文件,这是我感兴趣的解决方法。

If you see something like this from git status ... 如果您从git status看到类似的内容...

On branch gh-pages
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified: .DS_Store
    deleted: _posts/2019-06-06-First-Post.markdown
    deleted: _posts/2019-06-07-Ignite-Labs-Probduct-Update:-Inferno-v0.0.1(b).markdown
    deleted: _posts/2019-06-28-Project-Update.markdown
    deleted: about.md
    modified: assets/.DS_Store
    deleted: assets/graphy_boi.png

That means they were deleted from your filesystem. 这意味着它们已从您的文件系统中删除。 Git has no record of that. Git没有任何记录。

Things like the filenames and modification times are stored in the directory, the modification time of the directory will change whenever any files are changed, renamed, added, or deleted. 文件名和修改时间之类的东西都存储在目录中,只要更改,重命名,添加或删除任何文件,目录的修改时间就会改变。 ls -ld _posts/ assets/ will show you the last time this happened, though it won't necessarily be when those specific files were deleted. ls -ld _posts/ assets/将向您显示上一次发生的时间,尽管不一定是删除这些特定文件的时间。

It looks like you're using a CMS, so it likely happened when some CMS command was run. 看来您使用的是CMS,因此可能是在运行某些CMS命令时发生的。 You can check your command history with history . 您可以使用history检查命令历史history

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在本地工作目录,远程工作目录和git ftp目标中拥有不同版本的文件? - How can I have different versions of a file in the local working directory, remote working directory and git ftp target? 如何在git中找出文件的某些部分被删除? - How can I find out when some portion of a file was deleted in git? 在 Git 中查找文件何时被删除 - Find when a file was deleted in Git 在 git 中查找“被我们删除”文件何时被删除 - Find when a “deleted by us” file was deleted in git 在Bootcamp下共享驱动器上使用Git工作目录时,如何防止文件模式更改? - How can I prevent file mode changes when working with a Git working directory on a shared drive under Bootcamp? 如何在git中注释已删除的文件? - How can I annotate a deleted file in git? 如何在 Git 中归咎于已删除的文件? - How can I blame a deleted file in Git? Git 在重新创建符号链接后认为符号链接目录中的文件已被删除,我该如何解决? - Git thinks a file within a symlinked directory has been deleted after recreating the symlink, how can I fix it? 如何从git中删除从远程仓库中删除和忽略的本地文件? - How can I prevent my local files, which are deleted and ignored in remote repo, being deleted when pull from git? 我从 &#39;detached HEAD&#39; 状态返回并且 git 从本地目录中删除了我的 .env 文件 - I return from 'detached HEAD' state and git deleted my .env file from the local directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM