Remove a file from a Git repository without deleting it from the local filesystem

后端 未结 11 2186
陌清茗
陌清茗 2020-11-22 02:25

My initial commit contained some log files. I\'ve added *log to my .gitignore, and now I want to remove the log files from my repository.



        
11条回答
  •  情话喂你
    2020-11-22 02:56

    You can also remove files from the repository based on your .gitignore without deleting them from the local file system :

    git rm --cached `git ls-files -i -X .gitignore`
    

    Or, alternatively, on Windows Powershell:

    git rm --cached $(git ls-files -i -X .gitignore)
    

提交回复
热议问题