重置本地 git 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11910921/
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
Reset local git repository
提问by philologon
A few days ago I created a repository on Github, then followed the steps to add my existing solution to it. I have no idea what I did wrong, but after a few random 'git add' commands and whatnot, I now get the message in github for windows:
几天前,我在 Github 上创建了一个存储库,然后按照步骤将我现有的解决方案添加到其中。我不知道我做错了什么,但是在一些随机的“git add”命令之后,我现在在 Windows 的 github 中收到消息:
failed to sync this branch.
You might need to open a shell and debug the state of this repo.
Not gonna happen.
不会发生。
A better idea is that I delete the repository at github and start over with my local repository. I know how to delete the repository on github (I know it is easy because I have already done this once.) I am not sure how to start over locally. Is there a git command that is basically "git uninit" or "git deconstruct repository" ?
一个更好的主意是我删除 github 上的存储库并从我的本地存储库重新开始。我知道如何删除 github 上的存储库(我知道这很容易,因为我已经做过一次了。)我不知道如何在本地重新开始。是否有一个基本上是“git uninit”或“git deconstruct repository”的 git 命令?
回答by Matt Greer
Git stores everything about a repo at the repo's root in the hidden .git
folder. Simply deleting that folder, rm -rf .git
makes it as if there never was a repo there.
Git 将有关存储库的所有内容存储在隐藏.git
文件夹中的存储库根目录中。只需删除该文件夹,rm -rf .git
就好像那里从来没有回购过一样。
回答by Avi
- First Go to your local repo
- Show Hidden Files.
- You will see a ".git" named folder in your local repo.
- Delete That.
- Now open Github for Windows.
- If you click on that repo in Local Tab, you should get an Error that repo cant be found.
- There is it, click on Re-Clone Repository button.
- The Repo will be downloaded again and saved by default in My Documents/GitHub.
- 首先去你的本地仓库
- 显示隐藏文件。
- 您将在本地存储库中看到一个名为“.git”的文件夹。
- 删除那个。
- 现在打开 Windows 版 Github。
- 如果您在本地选项卡中单击该存储库,您应该会收到一个无法找到存储库的错误。
- 有它,单击 Re-Clone Repository 按钮。
- Repo 将再次下载并默认保存在 My Documents/GitHub 中。
回答by Jason Shehane
I got this error on GitHub for Windows when I had lost internet connection. Once I got connection back it sync'd up fine. Apparently the error messages on the windows client just aren't descriptive enough to tell you when you've lost connectivity. It was as simple as that.
当我失去互联网连接时,我在 GitHub for Windows 上收到此错误。一旦我恢复连接,它就同步好了。显然,Windows 客户端上的错误消息描述性不够,无法告诉您何时失去连接。就这么简单。
回答by AlanMo
git windows even can't clone the repo for me regardless I can clone it in git shell. I fixed it by following steps:
git windows 甚至无法为我克隆 repo,不管我可以在 git shell 中克隆它。我通过以下步骤修复了它:
- uninstall git for windows.
- restart windows.
- install git for windows.
- 卸载 git for windows。
- 重新启动窗口。
- 为 Windows 安装 git。
without restarting windows won't solve the problem, I did try.
不重新启动 Windows 不会解决问题,我确实尝试过。
回答by thinktt
I'm pretty sure I found this in another stackoverflow (if I see that one I'll put the link here) but restarting Windows actually fixes this problem for me. If I remember right, this is related to Github for Windows updating.
我很确定我在另一个 stackoverflow 中找到了这个(如果我看到那个,我会把链接放在这里)但是重新启动 Windows 实际上为我解决了这个问题。如果我没记错的话,这与 Github for Windows 更新有关。
There may be another way to get the app to update correctly and sync without restarting. Everytime I've had this issue though, restarting Windows fixes it.
可能还有另一种方法可以让应用程序正确更新并在不重新启动的情况下同步。每次我遇到这个问题时,重新启动 Windows 都会修复它。
回答by m-torin
There is another option that does not involve using the command line. It goes without saying that yes, you should know how to use it but if you are just learning it's not that simple.
还有另一种不涉及使用命令行的选项。不言而喻,是的,您应该知道如何使用它,但如果您只是在学习,它并不是那么简单。
Download TortoiseGit and right-click on the folder containing the repo. Go to TortoiseGit > Push and enter your login details. Badabing.
下载 TortoiseGit 并右键单击包含存储库的文件夹。转到 TortoiseGit > Push 并输入您的登录详细信息。八达宾。
I use it in tandem with the Github client. Life is easier/quicker now.
我将它与 Github 客户端一起使用。现在生活更轻松/更快。