How to delete the content of github repository?

11,442

Solution 1

In git, you can't delete the content of a branch. All you can do is to push a commit that removes all your files.
If you want to start over from a clean repository, you have to delete the current one a create a new one with the same name for example.

Solution 2

Just to support quentin's answer, adding the git commands:

  1. Keep a backup of the local repository folder and remove all its contents.

  2. Add these changes to commit

$ git add *
  1. Add a Commit message
$ git commit "Remove everything"
  1. Push changes
$ git push -f
Share:
11,442
MKH
Author by

MKH

I am eager to be a good iOS developer.

Updated on June 12, 2022

Comments

  • MKH
    MKH almost 2 years

    I wrongly pushed my code using Xcode toolbar into my repository on github. now, I want to delete all files in my master branch, but not the repository. Then I want to pull my code into repository this time instead of pushing. Does any one know how to delete all contents of master branch?