git 初始提交:“致命:无法创建...的前导目录”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23214892/
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
Initial Commit: "fatal: could not create leading directories of ..."
提问by Cheddar
I am trying to make the initial commit to a git repository on GitHub for a Unity project. I followed along with this guideto get to where I am. Note: For some reason or another, I couldn't set Unity's Asset Serialization Mode to Force Text, so I settled on Mixed (which I believe should work).
我正在尝试为 Unity 项目对 GitHub 上的 git 存储库进行初始提交。我跟随本指南到达我所在的位置。注意:出于某种原因,我无法将 Unity 的资产序列化模式设置为强制文本,因此我选择了混合(我认为应该可行)。
When I call git clone --bare . , I get an error.
当我调用 git clone --bare 时。,我收到一个错误。
Note that I am not the creator of the repository and only a contributor (though I am making the initial commit).
请注意,我不是存储库的创建者,而只是贡献者(尽管我是在进行初始提交)。
Here's everything in my terminal (I'm using Git Bash):
这是我终端中的所有内容(我使用的是 Git Bash):
Welcome to Git (version 1.8.4-preview20130916)
Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.
Cheddar@CHEDDAR-PC ~
$ cd Documents/ICS168Swarch/
Cheddar@CHEDDAR-PC ~/Documents/ICS168Swarch
$ git init
Initialized empty Git repository in c:/Users/Cheddar/Documents/ICS168Swarch/.git
/
Cheddar@CHEDDAR-PC ~/Documents/ICS168Swarch (master)
$ git add .
warning: LF will be replaced by CRLF in Assets/Prefabs.meta.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Prefabs/Pellet.prefab.meta.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Prefabs/PelletManager.prefab.meta
.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Prefabs/Player.prefab.meta.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Scene1.unity.meta.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Scripts.meta.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Scripts/EatPellets.cs.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Scripts/EatPellets.cs.meta.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Scripts/Movement.cs.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Scripts/Movement.cs.meta.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Scripts/SpawnPellets.cs.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Assets/Scripts/SpawnPellets.cs.meta.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Library/ScriptAssemblies/CompilationComp
leted.txt.
The file will have its original line endings in your working directory.
error: open("Temp/UnityLockfile"): Permission denied
error: unable to index file Temp/UnityLockfile
fatal: adding files failed
Cheddar@CHEDDAR-PC ~/Documents/ICS168Swarch (master)
$ git commit -m "[Initial project setup]"
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore.txt
# Assembly-CSharp-vs.csproj
# Assembly-CSharp.csproj
# Assembly-CSharp.pidb
# Assets/
# ICS168Swarch-csharp.sln
# ICS168Swarch.sln
# ICS168Swarch.userprefs
# Library/
# ProjectSettings/
# Temp/
nothing added to commit but untracked files present (use "git add" to track)
Cheddar@CHEDDAR-PC ~/Documents/ICS168Swarch (master)
$ git clone --bare . https://github.com/zarazha/swarch.git
fatal: could not create leading directories of 'https://github.com/zarazha/swarc
h.git'
Cheddar@CHEDDAR-PC ~/Documents/ICS168Swarch (master)
$
I searched for solutions to this, but nothing that I found seemed to have the same cause as what I am getting. Help on this is much appreciated!
我寻找了解决方案,但我发现的任何东西似乎都与我得到的原因相同。非常感谢这方面的帮助!
采纳答案by Dan Puzey
It looks as though you have two issues here.
看起来你在这里有两个问题。
First, you need a .gitignore
file that correctly limits the files you're adding to Git. This is covered in the tutorial you linked, but it seems you've not followed this correctly (as your add
is including files from the Temp
folder). Looking at your file list, it seems you've just named this file .gitignore.txt
by accident. Remove the file extension and then try starting again (re-run the git add
) and you'll get better results.
首先,您需要一个.gitignore
文件来正确限制您添加到 Git 的文件。这在您链接的教程中有所涉及,但您似乎没有正确遵循这一点(因为您add
包含了文件Temp
夹中的文件)。查看您的文件列表,您似乎只是.gitignore.txt
不小心命名了此文件。删除文件扩展名,然后尝试重新开始(重新运行git add
),您将获得更好的结果。
The problem with your clone
is that your second argument (the path "."
) is incorrect. It's not required (the default would be .
anyway), and if you do want to specify it, it comes afterthe repository, not before (see the Git docsfor details - <repository>
comes before <directory>
).
您的问题clone
在于您的第二个参数(路径"."
)不正确。它不是必需的(.
无论如何都是默认值),如果您确实想指定它,它会出现在存储库之后,而不是之前(有关详细信息,请参阅Git 文档-<repository>
出现在之前<directory>
)。
So, I think your clone should instead just be this:
所以,我认为你的克隆应该是这样的:
git clone --bare https://github.com/zarazha/swarch.git
回答by fwf
I have the same error. Just close unity and you are ready to go
我有同样的错误。只要紧密团结,你就可以出发了
回答by Juan Carlos Ospina Gonzalez
I also had this problem one time on MacOS. Turns out SourceTree was trying to clone to my /Developer/Projects folder. This is a system folder turns out. I changed to some other folder and it worked.
我在 MacOS 上也遇到过这个问题。结果 SourceTree 试图克隆到我的 /Developer/Projects 文件夹。原来这是一个系统文件夹。我换到了其他一些文件夹,它起作用了。