简体   繁体   English

如何使用新的本地项目覆盖远程git存储库

[英]How to overwrite remote git repository with a new local project

I don't have the permissions to delete/create a new repository so I would like clean out the one I have access to and overwrite it with a new project I started locally. 我没有删除/创建新存储库的权限,因此我想清理我可以访问的存储库,并用我在本地启动的新项目覆盖它。 I cannot find the instructions on how to do this. 我找不到有关如何执行此操作的说明。

You can add the repo as a remote to your new project, then use git push -f to destroy the repo's history and replace it with your own history. 您可以将存储库添加为新项目的远程存储,然后使用git push -f破坏存储库的历史记录并将其替换为您自己的历史记录。

That works equally well whether you're removing a single commit or replacing everything with a new history. 无论您要删除单个提交还是将所有内容替换为新的历史记录,这都同样有效。

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

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