如何重新初始化我的 git repo?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33906391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I re-init my git repo?
提问by cade galt
I've been doing some beginning work on a repo and I don't need the history.
我一直在做一些关于 repo 的开始工作,我不需要历史。
I want to start from ground zero w/ no history?
我想从零开始,没有历史?
Can I simply delete the .git
folder and run git init
again.
我可以简单地删除.git
文件夹并git init
再次运行吗?
But how will this effect my remote repos?
但这将如何影响我的远程存储库?
回答by PSkocik
cd "$PWD/`git rev-parse --show-cdup`" #go to the project's root
rm -rf .git
And then:
进而:
git init .
#...
As for your remote repos, you'll need to git push --force
into them (or push to a new, completely separate branch).
至于您的远程存储库,您需要git push --force
进入它们(或推送到一个新的、完全独立的分支)。