Remove file from the repository but keep it locally

Remove file from the repository but keep it locally

Asked on January 8, 2019 in Git.
Add Comment


  • 3 Answer(s)

    Try this below code:

    git rm --cached -r somedir
    
    

    Stage erasure the directory to touch anything on disk file.

    git rm --cached somefile.ext
    
    

    To add somedir/ or somefile.ext to your .gitignore file

    Answered on January 8, 2019.
    Add Comment

    Try this:

    • Move the folder out of your working tree
    • git rm the folder, commit the change
    • Add to .gitignore or .git/info/excludes, commit the change
    • Move the folder back
    Answered on January 8, 2019.
    Add Comment
    • Move the folder out of your working tree
    • git rm the folder, commit the change
    • Add to .gitignore (or .git/info/excludes), commit the change
    • Move the folder back
    Answered on February 20, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.