如何在 git 中查看未跟踪的文件而不是未跟踪的目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39030116/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:12:05  来源:igfitidea点击:

How to see untracked files in git instead of untracked directory

gitgithubgit-untracked

提问by Jumabek Alikhanov

git statusshows directory (e.g smaller_fc) is untracked. However, I want to see exactly which files inside the directories (e.g smaller_fc) are untracked.

git status显示目录(例如small_fc)未被跟踪。但是,我想确切地查看目录中的哪些文件(例如small_fc)未被跟踪。

I would like to know if .gitignore is indeed ignoring certain subdir inside smaller_fcdir.

我想知道 .gitignore 是否确实忽略了small_fc目录中的某些子目录

Here is terminal output.

这是终端输出。

$ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits)

$ git status 在 master 分支上您的分支领先于 'origin/master' 1 次提交。(使用“git push”来发布你的本地提交)

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)

未为提交暂存的更改:(使用“git add ...”更新将提交的内容)(使用“git checkout -- ...”放弃工作目录中的更改)

modified:   .gitignore

Untracked files: (use "git add ..." to include in what will be committed)

未跟踪的文件:(使用“git add ...”包含在将提交的内容中)

nets/models/500K_iterations/500K_iteration_eval.txt
nets/models/from_solverstate_150K/
nets/models/pretrained_model/
nets/models/smaller_fc/

.gitignore file:

.gitignore 文件:

.cproject
.project
.pydevproject
build
*~
*.pyc
*.caffemodel
*/solverstate/*

directory structure:

目录结构:

root
-models
--model1
---solverstate
----somefiles.txt
--model2
---solverstate
----anotherfiles.txt
.gitignore

Could not find it on google.

在谷歌上找不到它。

回答by mipadi

If git only shows that the directory is untracked, then every file in it (including files in subdirectories) is untracked.

如果 git 只显示目录未跟踪,则其中的每个文件(包括子目录中的文件)都未跟踪。



If you have some ignored files in the directory, pass the -uflag when running git status(i.e., git status -u) to show the status of individual untracked files.

如果目录中有一些被忽略的文件,请-u在运行时传递标志git status(即git status -u)以显示单个未跟踪文件的状态。