忽略的文件显示为未跟踪

时间:2019-02-11 14:50:01

标签: git

当我将项目移到存储库中的文件夹以保持所有内容井井有条时,整个问题就开始了。我想让令牌不在git范围内

我有一个.gitgnore,如下所示:

bot/__pycache__/*
bot/token
bot/staging_token
*.pyc

通过这种方式,我假定标记和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

我该怎么做才能使被忽略的文件不被跟踪?

1 个答案:

答案 0 :(得分:1)

您的输出将文件名显示为.gitgnore。它必须是.gitignore