- 如果此文件夾已被加入git追蹤,那么刪除方法很簡單,只需要將此文件夾刪掉,然后提交一下就可以了
- 如果次文件夾曾經被加入過git追蹤,現在被加入
.gitignore
里了,但是github上還有此文件夾。
對于這種情況,稍微有點復雜,因為已經加入.gitignore
的文件或文件夾,無法對其進行提交了,哪怕是將其刪除,都無法提交。
我們用以下方法可以很好的解決這個問題:
git rm -r --cached some-directory
git commit -m 'Remove the now ignored directory "some-directory"'
git push origin master
see more: Remove directory from remote repository after adding them to .gitignore