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

后端 未结 11 2037
陌清茗
陌清茗 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:51

    This depends on what you mean by 'remove' from git. :)

    You can unstage a file using git rm --cached see for more details. When you unstage something, it means that it is no longer tracked, but this does not remove the file from previous commits.

    If you want to do more than unstage the file, for example to remove sensitive data from all previous commits you will want to look into filtering the branch using tools like the BFG Repo-Cleaner.

提交回复
热议问题