Git:清除本地和远程仓库并重新开始
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15685074/
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
Git: Clear local and remote repo and start over
提问by RockyMountainHigh
I accidentally got a repo in a bad state when trying to move a project from using ant to maven. Now, I would like to clear the repo and startover from scratch. Being new to git, I am a little cautious and not sure if I could just checkout then delete all files and folders locally then push to the remote repo or if that was actually a very bad idea. For some reason I'm having a hard time asking the correct questions in google. :D
在尝试将项目从使用 ant 转移到 maven 时,我不小心得到了状态不佳的 repo。现在,我想从头开始清除回购和重新启动。作为 git 的新手,我有点谨慎,不确定我是否可以结帐,然后在本地删除所有文件和文件夹,然后推送到远程存储库,或者这是否实际上是一个非常糟糕的主意。出于某种原因,我很难在谷歌中提出正确的问题。:D
回答by Ruslan Osipov
Simply remove local .git
directory, remove repo from server (if it is github - do Repo -> setiings -> remove).
只需删除本地.git
目录,从服务器中删除 repo(如果是 github - do Repo -> setiings -> remove)。
Then create new repository on server, and locally do:
然后在服务器上创建新的存储库,并在本地执行:
git init
git remote add origin [email protected]:user/project.git
git add .
git commit -m "Initial commit"
git push -u origin master
回答by shattenjager
In my case I just wanted to refresh the local repo, I used Ruslan answer without the last two commands since I didn't need to do anything on the server side, and it worked perfectly! Of course I deleted the .git
file locally as suggested without removing the remote directory before to execute the commands. Thanks!
在我的情况下,我只想刷新本地存储库,我使用了 Ruslan answer 而不使用最后两个命令,因为我不需要在服务器端做任何事情,而且它工作得很好!当然,我.git
按照建议在本地删除了文件,而在执行命令之前没有删除远程目录。谢谢!