linux - 将之前忽略的目录添加到 Git 存储库

标签 linux git

我的 .gitignore 文件看起来像:

html/
cache/
resources/
# Temp files often created by editors
*.~

我知道希望开始跟踪 html 中的特定目录,所以我添加 `!html/support/

html/
cache/
resources/
# Temp files often created by editors
*.~
# Track support
!html/support/

然而,这样做之后,Git 似乎仍然没有跟踪 html/support/及其所有子项。

如何将之前忽略的目录添加到 Git 存储库?

最佳答案

不忽略不代表跟踪。

就用

git add html/support/

在您的 git 存储库的根目录下。

如果文件仍然被忽略,你可以使用 git add -f 强制添加它(这不会修改 .gitignore 文件,只允许一个几乎没有异常(exception)):

git add -f html/support/

关于linux - 将之前忽略的目录添加到 Git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23296370/

相关文章:

python - 我如何在 Python 中的两个不同进程之间共享一个串口

linux - 设置 Linux 树命令的默认级别选项

git - 为什么 git 在每次 merge 时都运行 "git gc --auto"?

git - 撤消旧提交中对特定文件的更改,不留下任何痕迹

git - 如何 git svn 获取较旧的历史记录?

linux - 是否可以查看正在运行但已修改的 bash 脚本的原始内容?

linux - pause() 系统调用并接收 SIGINT 信号

linux - 完全合格的域名是否需要句点?

git - 我应该忽略在 Git 中提交的 launchSettings.json 文件吗?

git - 将一个 Git 存储库的所有分支导入到另一个 Git 存储库中