Search code examples
gitgithubrm

How to git rm files that are on remote origin but not in local?


I have some .swp files that were created by my editor and committed previously by accident. Now I want to merge into master, but need to get rid of these files. I tried to delete them from my working copy, and then commit. Now the files are deleted locally but still present in the commit on github. I have tried git rm path_to_files, but this returns fatal: pathspec 'path_to_files' did not match any files, which seems to confirm that they are totally gone from my local copy. How can I remove them entirely? Thanks.


Solution

  • Since your files are deleted locally from the file system, you should be able to do:

    git add . -A
    git commit -m 'Deleted files'
    

    Or just:

    git commit -m 'Deleted files' .
    

    (notice the point at the end, that will add the deleted files)