git - 忽略的文件显示为未跟踪
问题描述
当我将项目移动到存储库中的一个文件夹以保持一切井井有条时,整个问题就开始了。我想将令牌保留在 git 范围之外
我有一个.gitgnore
如下:
bot/__pycache__/*
bot/token
bot/staging_token
*.pyc
由此我假设不应该跟踪 token 和 staging_token 。尽管如此, git status 显示:
Untracked files:
(use "git add <file>..." to include in what will be committed)
bot/staging_token
bot/token
我已经完成了git rm -r --cached .
,然后git add .
。之后,两个令牌仍被添加到暂存区。
为了对其进行测试,我还将 bot/* 添加到.gitgnore
并重复git rm -r --cached .
. 输出:
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: .gitgnore
deleted: Dockerfile
deleted: bot/main.py
deleted: bot/portfolio.py
deleted: bot/reply_messages.py
deleted: bot/requirements.txt
deleted: bot/telegram_commands.txt
deleted: bot/telegram_interface.py
deleted: bot/ticker.py
deleted: bot/yfinance.py
deleted: readme.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitgnore
Dockerfile
bot/
readme.md
和 git add .. 这是输出:
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: .gitgnore
new file: bot/staging_token
new file: bot/token
我应该怎么做才能使被忽略的文件不被跟踪?
解决方案
您的输出将文件名显示为.gitgnore
. 它必须是.gitignore
。
推荐阅读
- bamboo - 带有额外 Maven 存储库的竹 Java 规范
- javascript - 仅在选中复选框时从 HTML 获取值(HTML + Python 脚本)
- reactjs - React 已经在渲染时无法刷新更新
- c# - 如何在 Blazor 的 c# 中取消 BlockBlobClient 上传中间流?
- amazon-web-services - terraform 有条件地创建 ECR 存储库(如果不存在)
- css - 有没有办法在保持大部分原始风格的同时对反应选择进行风格化?
- android - 未验证的应用程序屏幕未显示
- python - 如何编写 python 脚本将指标数据发送到 pushgateway
- android - 在不使用片段的情况下构建首选项屏幕的最佳 Compose 方法是什么?
- excel - 在PowerPoint中嵌入excel数据