簡體   English   中英

.gitignore 不會忽略未跟蹤的文件

[英].gitignore is not ignoring untracked files

我不明白為什么我的.gitignore文件沒有按預期工作。 它被添加到我的倉庫中。 它無法忽略__pycache__子文件夾以及我添加用於測試.gitignore功能的test.xyz

.gitignore內容:

__pycache__/
src/__pycache__
*.py[cod]
*.csv
**/*.pyc
*.pyc
*.xlsx
*.xyz

當我運行git status時會發生什么:

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

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        src/__pycache__/
        tst.xyz

nothing added to commit but untracked files present (use "git add" to track)

請指教。

編輯:
這是文件夾結構:

repo/
 |
 | src/
 |  | __pycache__/
 |
 | tests/
 |
 | .gitignore
 | LICENSE

對 .gitignore 文件進行更改后,您應該執行以下操作

# git commit -m "before updating gitignore"
git rm -r --cached .
git add .
git commit -m ".gitignore updated"

要對其進行測試,請嘗試修改任何被忽略的文件,運行git status並且您將無需提交任何內容(工作樹清理)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM