git 状态不显示新文件夹
git status doesn't show new folder
在我的项目中添加新文件夹后,我无法将它们视为 untracked
文件,例如,如果我添加 js
文件夹,我无法使用 git status
命令查看它们.(我也试过了git status -u
)
(注意: 我可以在 git clean -nd
中看到 js
文件夹)
如何在 git 中实现将新文件夹添加到我的项目中?
第二个相关的问题是:
当我在 js
文件夹中添加 index.js
时,我收到以下消息:
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
js/
nothing added to commit but untracked files present (use "git add" to track)
为什么我看不到 index.js
是未跟踪的文件而不是 js
文件夹?
或类似 js/index.js
或者更好的问题是如何查看 js
文件夹中的新内容?
我试图在 Whosebug 问题 和 [=48= 中找到答案] 文件 但我做不到。
Git 无法跟踪空目录,因此您将看不到 js
目录。它不会查看未跟踪的目录内部,因此如果您在其中有文件,它们将不会单独显示在 git status
中。只有目录是可见的。
通常,人们会在空目录中添加 .track
,以便跟踪空目录。
第二题
你可以做到 git add js/
它也会添加 index.js 文件
完成上述步骤后您可以尝试git status
那么你将得到:
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
**modified: js/index.js**
对于第一个问题,git status
应该显示未跟踪的文件夹及其路径。如果它不适合你才奇怪。
Untracked files:
(use "git add <file>..." to include in what will be committed)
js/
如前所述,默认情况下 git status
不会显示未跟踪目录中的文件。
要明确要求,您可以使用:
git status --untracked-files
这将显示:
Untracked files:
(use "git add <file>..." to include in what will be committed)
js/index.js
在我的项目中添加新文件夹后,我无法将它们视为 untracked
文件,例如,如果我添加 js
文件夹,我无法使用 git status
命令查看它们.(我也试过了git status -u
)
(注意: 我可以在 git clean -nd
中看到 js
文件夹)
如何在 git 中实现将新文件夹添加到我的项目中?
第二个相关的问题是:
当我在 js
文件夹中添加 index.js
时,我收到以下消息:
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
js/
nothing added to commit but untracked files present (use "git add" to track)
为什么我看不到 index.js
是未跟踪的文件而不是 js
文件夹?
或类似 js/index.js
或者更好的问题是如何查看 js
文件夹中的新内容?
我试图在 Whosebug 问题 和 [=48= 中找到答案] 文件 但我做不到。
Git 无法跟踪空目录,因此您将看不到 js
目录。它不会查看未跟踪的目录内部,因此如果您在其中有文件,它们将不会单独显示在 git status
中。只有目录是可见的。
通常,人们会在空目录中添加 .track
,以便跟踪空目录。
第二题
你可以做到 git add js/
它也会添加 index.js 文件
完成上述步骤后您可以尝试git status
那么你将得到:
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
**modified: js/index.js**
对于第一个问题,git status
应该显示未跟踪的文件夹及其路径。如果它不适合你才奇怪。
Untracked files:
(use "git add <file>..." to include in what will be committed)
js/
如前所述,默认情况下 git status
不会显示未跟踪目录中的文件。
要明确要求,您可以使用:
git status --untracked-files
这将显示:
Untracked files:
(use "git add <file>..." to include in what will be committed)
js/index.js