Git 查詢與取消 skip-worktree
如果改過已追蹤的檔案卻在 git status 找不到,先用 git ls-files -v 看索引裡的旗標。 S 或 s 表示路徑設了 skip-worktree ,小寫代表也設了 assume-unchanged 。若這些旗標是先前為了隱藏本機修改手動設定的,可以取消後重查。
git ls-files -v -- config.local.json
git update-index --no-skip-worktree -- config.local.json
git update-index --no-assume-unchanged -- config.local.json
git status --short -- config.local.json
skip-worktree 主要用於 sparse-checkout。要縮小工作目錄的範圍,用 git sparse-checkout 設定要保留的目錄。要讓設定檔在每個人的電腦各自維護,可以追蹤範本,另外忽略實際使用的本機檔。
兩種用途的選法與實測,已併入 Git 的 .gitignore 與 .git/info/exclude 怎麼選。
參考資料
26 November 2026