git 致命错误带有 a 的路径没有意义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11914919/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:19:21  来源:igfitidea点击:

git fatal error Path with a does not make sense

gitsourceforge

提问by BAD_SEED

I have existing code on my computer, then I have registerd my account on sourceforge, starting a git project. Now I need to send my local project on sourceforge remote space. On sf there's the instruction page:

我的电脑上已有代码,然后我在 sourceforge 上注册了我的帐户,开始了一个 git 项目。现在我需要在 sourceforge 远程空间上发送我的本地项目。在 SF 上有说明页面:

First time using Git

第一次使用 Git

cd miorep-code
git init
git commit -a -m 'Initial commit'
git remote add origin ssh://****/p/miorep/code
git push origin master

Existing Repository

现有存储库

cd miorep-code
git remote add origin ssh://****/p/miorep/code
git push origin master

If I follow the first set of instructions, I have a

如果我按照第一组说明进行操作,我将有一个

"Fatal: Paths with -a does not make sense"

“致命:带有 -a 的路径没有意义”

when I get git commit -a -m 'Initial commit'.

当我得到git commit -a -m 'Initial commit'.

If I follow the second set of instruction I get:

如果我遵循第二组指令,我会得到:

error: src refspec master does not match any. error: failed to push some refs to 'ssh://**/p/ravenna/code'

错误:src refspec master 不匹配。错误:无法将一些引用推送到“ssh:// **/p/ravenna/code”

when I exec the last command.

当我执行最后一个命令时。

What's the correct set of instructions in my case? Why I get that error?

在我的情况下,正确的指令集是什么?为什么我得到那个错误?

采纳答案by larsks

The first set of instructions don't make sense:

第一组指令没有意义:

cd miorep-code
git init
git commit -a -m 'Initial commit'

There needs to be a git addbetween git initand git commit, because otherwise gitdoesn't know whatyou want to commit. Your second error...

git add之间需要有一个,否则不知道你想提交什么。你的第二个错误...git initgit commitgit

error: src refspec master does not match any. error: failed to push some refs to 'ssh://**/p/ravenna/code'

...means you haven't actually committed anything to your local repository yet, so there is no masterbranch to push.

...意味着您实际上还没有向本地存储库提交任何内容,因此没有master要推送的分支。

What you want to do is:

你想要做的是:

cd miorep-code
git init
git add .
git commit -m 'initial commit'
git push origin master

You'll note that this is almostidentical to your first set of instructions, except we've add a git add .which means "add everything in my current directory and below to my repository".

您会注意到这与您的第一组指令几乎相同,除了我们添加了一个git add .意思是“将我当前目录中和下面的所有内容添加到我的存储库中”。

回答by Tim Long

The single-quote ' is the problem. Change it to double-quotes, like "initial commit". Use double-quotes in Windows-cmdinstead of single-quote.

单引号 ' 是问题所在。将其更改为双引号,例如“初始提交”。在Windows-cmd 中使用双引号而不是单引号。

@AndrewC: read this before doing the downvote: http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository#Skipping-the-Staging-Area

@AndrewC:在做downvote之前阅读这个:http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository#Skipping-the-Staging-Area