代码之家  ›  专栏  ›  技术社区  ›  Ray Tayek

如何从git repo中删除文件?

git
  •  -1
  • Ray Tayek  · 技术社区  · 7 年前

    似乎无法从git中删除文件。

    我的视力很差,有人能看出我做错了什么吗?

    编辑:这是一种类型。我正在删除错误的文件:(

    谢谢

    D:\ray\dev\ml\titanic>git rm .ipynb_checkpoints/tryunitesting.ipynb
    fatal: pathspec '.ipynb_checkpoints/tryunitesting.ipynb' did not match any files
    
    
    D:\ray\dev\ml\titanic>git rm .ipynb_checkpoints\tryunitesting.ipynb
    fatal: pathspec '.ipynb_checkpoints\tryunitesting.ipynb' did not match any files
    
    
    D:\ray\dev\ml\titanic>ls .ipynb_checkpoints
    tryunitesting-checkpoint.ipynb
    
    D:\ray\dev\ml\titanic>
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Kerem Sanjucta    7 年前
    git rm file1.txt
    git commit -m "remove file1.txt"
    

    但如果只想从Git存储库中删除文件,而不想从文件系统中删除,请使用:

    git rm --cached file1.txt
    git commit -m "remove file1.txt"
    

    并将更改推送到远程回购

    git push origin branch_name  
    

    看来是你的问题 typo 。为了避免像这样的简单错误,您可以使用一些shell插件。请检查 this great plugin