Git - how delete file from remote repository

How can I delete file from remote git repository? I have a file that is just deleted from working copy local repository, and I want delete it from corresponding remote repository


Solution 1:

If you deleted a file from the working tree, then commit the deletion:

git commit -a -m "A file was deleted"

And push your commit upstream:

git push

Solution 2:

Use commands :

git rm /path to file name /

followed by

git commit -m "Your Comment"

git push

your files will get deleted from the repository

Solution 3:

  1. If you want to push a deleted file to remote

git add 'deleted file name'

git commit -m'message'

git push -u origin branch

  1. If you want to delete a file from remote and locally

git rm 'file name'

git commit -m'message'

git push -u origin branch

  1. If you want to delete a file from remote only

git rm --cached 'file name'

git commit -m'message'

git push -u origin branch

Solution 4:

A simpler way

git add . -A
git commit -m "Deleted some files..."
git push origin master

-A Update the index not only where the working tree has a file matching but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree. Taken from (http://git-scm.com/docs/git-add)

Solution 5:

If you pushed a file or folder before it was in .gitignore (or had no .gitignore):

  • Comment it out from .gitignore
  • Add it back on the filesystem
  • Remove it from the folder
  • git add your file && commit it
  • git push