How can I delete a file from a Git repository?

后端 未结 24 2015
無奈伤痛
無奈伤痛 2020-11-22 13:41

I have added a file named \"file1.txt\" to a Git repository. After that, I committed it, added a couple of directories called dir1 and dir2

24条回答
  •  悲哀的现实
    2020-11-22 14:13

    1. First,Remove files from local repository.

      git rm -r File-Name

      or, remove files only from local repository but from filesystem

      git rm --cached File-Name

    2. Secondly, Commit changes into local repository.

      git commit -m "unwanted files or some inline comments"   
      
    3. Finally, update/push local changes into remote repository.

      git push 
      

提交回复
热议问题