是否有撤消 git init 的命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3212459/
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
Is there a command to undo git init?
提问by Yarin
I just Git init'ed a repos with a wrong user, and want to undo it. Is there any command for this? Do I actually have to go in and edit the .git directory?
我只是用一个错误的用户 Git 初始化了一个存储库,并想撤消它。有没有这方面的命令?我真的必须进入并编辑 .git 目录吗?
回答by Matthew Flaschen
You can just delete .git. Typically:
你可以删除.git。通常:
rm -rf .git
Then, recreate as the right user.
然后,重新创建为正确的用户。
回答by wordsforthewise
In windows, type rmdir .git
or rmdir /s .git
if the .git folder has subfolders.
在 Windows 中,键入rmdir .git
或者rmdir /s .git
.git 文件夹是否有子文件夹。
If your git shell isn't setup with proper administrative rights (i.e. it denies you when you try to rmdir
), you can open a command prompt (possibly as administrator--hit the windows key, type 'cmd', right click 'command prompt' and select 'run as administrator) and try the same commands.
如果您的 git shell 没有设置适当的管理权限(即它在您尝试时拒绝您rmdir
),您可以打开命令提示符(可能以管理员身份 - 点击 windows 键,键入“cmd”,右键单击“命令提示符” ' 并选择 '以管理员身份运行) 并尝试相同的命令。
rd
is an alternative form of the rmdir
command. http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/rmdir.mspx?mfr=true
rd
是rmdir
命令的另一种形式。http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/rmdir.mspx?mfr=true
回答by Kris Roofe
回答by Dominic Davies
I'm running Windows 7 with git bash console. The above commands wouldn't work for me.
我正在使用 git bash 控制台运行 Windows 7。上面的命令对我不起作用。
So I did it via Windows Explorer. I checked show hidden files, went to my projects directory and manually deleted the .git folder. Then back in the command line I checked by running git status.
所以我是通过 Windows 资源管理器完成的。我检查了显示隐藏文件,转到我的项目目录并手动删除了 .git 文件夹。然后回到命令行,我通过运行 git status 进行了检查。
Which returned...
哪个返回...
fatal: Not a git repository (or any of the parent directories): .git
致命:不是 git 存储库(或任何父目录):.git
Which is exactly the result I wanted. It returned that the directory is not a git repository (anymore!).
这正是我想要的结果。它返回该目录不是 git 存储库(不再是!)。
回答by Luca C.
remove the .git
folder in your project root folder
删除.git
项目根文件夹中的文件夹
if you installed submodules and want to remove their git, also remove .git
from submodules folders
如果您安装了子模块并想删除它们的 git,也请.git
从子模块文件夹中删除