Git gitignore 失效問題解決

poliyka
May 23, 2023

--

gitignore的檔案若已經commit的話,gitignore並不會生效,目前git也沒有automatic去清除,必須手動清除cache

刪除在.gitgnore中的檔案: 以下二擇一

git rm -r — cached .

git rm --cached `git ls-files -i -c --exclude-from=.gitignore`

新增刪除的檔案到commit區

git add .

然後新增一個 commit 即可

git commit -m "fixed untracked files"​

git push origin <branch-name> 後,遠端repo上的檔案也會隨之移除

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response