简体   繁体   中英

How to delete the content of github repository?

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?

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.

我制作了一个有助于解决这个问题的工具 .. 它不需要您输入您的身份验证令牌,因为 netlify 会为您处理它:) 查看https://repo-cleaner.netlify.com

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

删除 git 仓库并创建一个同名的新仓库

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM