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

后端 未结 11 2262
陌清茗
陌清茗 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 03:02

    As per my Answer here: https://stackoverflow.com/questions/6313126/how-to-remove-a-directory-in-my-github-repository

    To remove folder/directory or file only from git repository and not from the local try 3 simple steps.


    Steps to remove directory

    git rm -r --cached File-or-FolderName
    git commit -m "Removed folder from repository"
    git push origin master
    

    Steps to ignore that folder in next commits

    To ignore that folder from next commits make one file in root named .gitignore and put that folders name into it. You can put as many as you want

    .gitignore file will be look like this

    /FolderName
    

    remove directory

提交回复
热议问题