Skip to main content

How to Delete Files and Folders on GitHub

Short answer

GitHub's web interface does not have a dedicated 'delete folder' button — it only allows you to delete individual files. To delete an entire folder via the web, you must delete every file inside it one by one; GitHub automatically removes the folder itself once it contains no files. The more practical approach is to delete the folder locally with rm -rf path/to/folder, stage the deletion with git add -A or git rm -r path/to/folder, commit with git commit -m "Remove folder", and push. Once the push is received, the folder disappears from the GitHub repository view. Always confirm the folder contents before deleting, and coordinate with teammates if others may be actively working on files inside it.

The web interface on GitHub.com allows you to do basic editing tasks. You can delete a specific file after opening its detail view and then clicking on the little trash can icon:

However, you cannot delete multiple files in one go nor can you delete folders in the GitHub web interface.

These tasks must be performed in a local repository, after cloning it to your computer. For an in-depth tutorial on how to clone and work with a local repository, take a look at our free online book on learning Git.

How to Delete Files and Folders in a Local Git Repository

If you're using Git in a desktop GUI like the Tower Git client, you can simply select one or more items - both files and folders - and delete them:

In case you're using Git on the command line, you can use the following commands:

# To delete a file:
$ git rm my-file.txt

# To delete a folder, add the '-r' option:
$ git rm -r my-folder

After deleting the file or folder, don't forget to commit the deletion to record it in the repository.

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!

Free. We email you a ZIP with our cheat sheets.


Learn More

  • Check out our command overview on git rm

Free download

Download the Cheat Sheet

Get 18 of our most popular Cheat Sheets in one handy ZIP!