Git:如何重置远程 Git 存储库以删除所有提交? [英] Git: How to reset a remote Git repository to remove all commits?
本文介绍了Git:如何重置远程 Git 存储库以删除所有提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何重置远程和本地 Git 存储库以删除所有提交?
How can I reset a remote and local Git repository to remove all commits?
我想以当前 Head 作为初始提交重新开始.
I would like to start fresh with the current Head as the initial commit.
推荐答案
完全重置?
在本地删除
.git
目录.
重新创建 git 存储库:
Recreate the git repostory:
$ cd (project-directory)
$ git init
$ (add some files)
$ git add .
$ git commit -m 'Initial commit'
推送到远程服务器,覆盖.请记住,这样做会使其他所有人都陷入困境……您最好成为唯一的客户.
Push to remote server, overwriting. Remember you're going to mess everyone else up doing this … you better be the only client.
$ git remote add origin <url>
$ git push --force --set-upstream origin master
这篇关于Git:如何重置远程 Git 存储库以删除所有提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文