Description:
以 android project 為例,大多數的情況下,不需要追蹤 /bin 資料夾裡的檔案。但若已經將bin資料夾加入追蹤。要如何讓 bin 回到 untrack 的狀態?
Solution:
1.移動到 project 根目錄下輸入
git rm –cached -r bin
rm 'bin/AndroidManifest.xml' rm 'bin/R.txt' rm 'bin/classes/android/support/v7/appcompat/R$anim.class' rm 'bin/classes/android/support/v7/appcompat/R$attr.class' rm 'bin/classes/android/support/v7/appcompat/R$bool.class' rm 'bin/classes/android/support/v7/appcompat/R$color.class' rm 'bin/classes/android/support/v7/appcompat/R$dimen.class' rm 'bin/classes/android/support/v7/appcompat/R$drawable.class' rm 'bin/classes/android/support/v7/appcompat/R$id.class' rm 'bin/classes/android/support/v7/appcompat/R$integer.class' rm 'bin/classes/android/support/v7/appcompat/R$layout.class' rm 'bin/classes/android/support/v7/appcompat/R$string.class' rm 'bin/classes/android/support/v7/appcompat/R$style.class' ...
2.
commit 該動作。(git commit)
[master 846ecc5] [Test] Ignore all files in /bin folder. 31 files changed, 620 deletions(-) delete mode 100644 bin/AndroidManifest.xml delete mode 100644 bin/R.txt delete mode 100644 bin/classes/android/support/v7/appcompat/R$anim.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$attr.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$bool.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$color.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$dimen.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$drawable.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$id.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$integer.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$layout.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$string.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$style.class delete mode 100644 bin/classes/android/support/v7/appcompat/R$styleable.class ...
3.
使用 git status 查詢,可以看到 bin 資料夾已經回到 untracked 狀態。
# On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # bin/ nothing added to commit but untracked files present (use "git add" to track)