简体   繁体   English

有没有办法删除所有文件并在github上提交

[英]Is there way to delete all files and commits on github

I want to delete all files and commits on my github repository. 我想删除所有文件并在我的github仓库上提交。 But I don't want to destroy the repo. 但我不想破坏该回购协议。 Stars should be stay. 星星应该留下来。 Is it possible? 可能吗?

Being in the project's directory: 在项目目录中:

rm -rf .git/
git rm -r *
git init
git add .
git remote add origin projects_url
git commit -m "Remove everything"
git push -u --force origin master

Push an empty local repo with the --mirror flag --mirror标志推送一个空的本地--mirror

$ mkdir practice; cd practice;
$ git init; git remote add origin git@github.com:user/practice.git;

$ git push origin --mirror
remote: error: refusing to delete the current branch: refs/heads/master
To git@github.com:user/practice.git
 ! [remote rejected] master (deletion of the current branch prohibited)
error: failed to push some refs to 'git@github.com:user/practice.git'

On GitHub you can get around this by making an initial commit then pushing. 在GitHub上,您可以通过进行初始提交然后推送来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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