Here is the scenario:
以下是场景:
i uninstalled xcode and git removed by uninstalling , my local commits are gone. but i can see .git folder in my project and it is not empty.
我卸载了Xcode和通过卸载删除的Git,我的本地提交也不见了。但我可以在我的项目中看到.git文件夹,而且它不是空的。
when i run any commands of git it says : fatal: not a git repository (or any of the parent directories): .git
当我运行git的任何命令时,它都会说:致命:不是git存储库(或任何父目录):.git
also when i run git init
i get this : error: failed to write new configuration file /Users/myuser/Desktop/xxxproject/.git/config.lock
fatal: could not set 'core.repositoryformatversion' to '0'
另外,当我运行git init时,我收到以下消息:错误:无法写入新配置文件/Users/myuser/Desktop/xxxproject/.git/config.lock致命错误:无法将‘core.repositoryFormatVersion’设置为‘0’
is there any way to recover commits? :)
有什么方法可以恢复提交吗?:)
更多回答
Sounds like you don't have permissions to read from (or write to) the .git folder from the shell. Or maybe only to some critical files in it.
听起来您没有从外壳程序读取(或写入).git文件夹的权限。或者可能仅限于其中的一些关键文件。
@fredrik so is there any solutions?
@弗雷德里克,那么有什么解决方案吗?
Fix the permissions if that's the issue - I don't know how to do that in a MacOS system though.
如果这是问题所在,请修改权限--不过我不知道如何在MacOS系统中做到这一点。
chmod in terminal, to change your permission. but uninstalling xcode shouldn't delete your local commits. are you sure you're running from the same folder that the .git folder lies in?
Chmod在终端中,更改您的权限。但是卸载Xcode不应该删除您的本地提交。是否确实要从.git文件夹所在的同一文件夹中运行?
@A-_-S yes the path is correct. i got the permission by sudo chmod -R u+rwx .git and now i can run git commands but still cannot recover changes. for example when i run git status
i get this : error: short read while indexing .gitignore and same error for some other files
@A-S:是的,这条路是正确的。我通过sudo chmod-Ru+rwx.git获得了权限,现在我可以运行git命令,但仍然无法恢复更改。例如,当我运行GIT Status时,我收到了这样的消息:Error:Short Read When Indeindex.gitignore,对其他一些文件也是同样的错误
我是一名优秀的程序员,十分优秀!