致命:似乎不是 git 存储库

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

fatal: does not appear to be a git repository

gitgit-remote

提问by Jitendra Vyas

Why am I getting this error when my git repository url is correct?

当我的 git 存储库 url 正确时,为什么会出现此错误?

jitendra@JITENDRA-PC /c/mySite (master)
$ git push beanstalk master
fatal: '[email protected]/gittest.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

jitendra@JITENDRA-PC /c/mySite (master)
$ git clone git://github.com/jquery/jquery.git
Cloning into jquery...
Remote: Counting objects: 19803, done.
Remote: Compressing objects: 100% (5196/5196), done.
Remote: Total 19803 (delta 14204), reused 19549 (delta 14052)
Receiving objects: 100% (19803/19803), 12.80 MiB | 591 KiB/s, done.
Resolving deltas: 100% (14204/14204), done.

jitendra@JITENDRA-PC /c/mySite (master)
$ gitk --all

jitendra@JITENDRA-PC /c/mySite (master)
$ gitk -all

jitendra@JITENDRA-PC /c/mySite (master)
$ git remote add origin [email protected]/gittest.git

jitendra@JITENDRA-PC /c/mySite (master)
$ git push origin master
fatal: '[email protected]/gittest.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

jitendra@JITENDRA-PC /c/mySite (master)

Edit: Replaced original screenshot

编辑:替换原始截图

EDIT:

编辑:

fatal: '[email protected]/gittest.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

回答by Mark Longair

You've got the syntax for the scp-style way of specifying a repository slightly wrong - it has to be:

scp指定存储库的-style 方式的语法略有错误 - 它必须是:

[user@]host.xz:path/to/repo.git/

... as you can see in the git clonedocumentation. You should use instead the URL:

...正如您在git clone文档中看到的那样。您应该改用 URL:

[email protected]:/gittest.git

i.e. in the URL you're using, you missed out the :(colon)

即在您使用的 URL 中,您错过了:(冒号)

To update the URL for origin you could do:

要更新来源的 URL,您可以执行以下操作:

git remote set-url origin [email protected]:/gittest.git

回答by vHow

I met a similar problem when I tried to store my existing repo in my Ubunt Oneaccount, I fixed it by the following steps:

当我尝试将现有存储库存储在我的Ubunt One帐户中时遇到了类似的问题,我通过以下步骤修复了它:

Step-1: create remote repo

步骤 1:创建远程仓库

$ cd ~/Ubuntu\ One/
$ mkdir <project-name>
$ cd <project-name>
$ mkdir .git
$ cd .git
$ git --bare init

Step-2: add the remote

第二步:添加遥控器

$ git remote add origin /home/<linux-user-name>/Ubuntu\ One/<project-name>/.git

Step-3: push the exising git reop to the remote

第 3 步:将现有的 git reop 推送到远程

$ git push -u origin --all

回答by rizon

This is typically because you have not set the origin alias on your Git repository.

这通常是因为您尚未在 Git 存储库上设置原始别名。

Try

尝试

git remote add origin URL_TO_YOUR_REPO

This will add an alias in your .git/configfile for the remote clone/push/pull site URL. This URL can be found on your repository Overview page.

这将在您的.git/config文件中为远程克隆/推/拉站点 URL添加一个别名。该 URL 可以在您的存储库概览页面上找到。

回答by JamesAD-0

my local and remote machines are both OS X. I was having trouble until I checked the file structure of the git repo that xCode Server provides me. Essentially everything is chmod 777 * in that repo so to setup a separate non xCode repo on the same machine in my remote account there I did this:

我的本地和远程机器都是 OS X。在检查 xCode Server 提供给我的 git 存储库的文件结构之前,我遇到了问题。基本上所有东西都是 chmod 777 * 在那个 repo 中,所以为了在我的远程帐户的同一台机器上设置一个单独的非 xCode repo,我这样做了:

REMOTE MACHINE

远程机器

  1. Login to your account
  2. Create a master dir for all projects 'mkdir git'
  3. chmod 775 git then cd into it
  4. make a project folder 'mkdir project1'
  5. chmod 777 project1 then cd into it
  6. run command 'git init' to make the repo
  7. this creates a .git dir. do command 'chmod 777 .git' then cd into it
  8. run command 'chmod 777 *' to make all files in .git 777 mod
  9. cd back out to myproject1 (cd ..)
  10. setup a test file in the new repo w/command 'touch test.php'
  11. add it to the repo staging area with command 'git add test.php'
  12. run command "git commit -m 'new file'" to add file to repo
  13. run command 'git status' and you should get "working dir clean" msg
  14. cd back to master dir with 'cd ..'
  15. in the master dir make a symlink 'ln -s project1 project1.git'
  16. run command 'pwd' to get full path
  17. in my case the full path was "/Users/myname/git/project1.git'
  18. write down the full path for later use in URL
  19. exit from the REMOTE MACHINE
  1. 登录到您的帐户
  2. 为所有项目“mkdir git”创建一个主目录
  3. chmod 775 git 然后 cd 进去
  4. 创建一个项目文件夹“mkdir project1”
  5. chmod 777 project1 然后 cd 进去
  6. 运行命令 'git init' 来制作 repo
  7. 这将创建一个 .git 目录。执行命令 'chmod 777 .git' 然后 cd 进入
  8. 运行命令 'chmod 777 *' 以生成 .git 777 mod 中的所有文件
  9. cd 回到 myproject1 (cd ..)
  10. 在带有命令“touch test.php”的新仓库中设置一个测试文件
  11. 使用命令 'git add test.php' 将其添加到 repo 暂存区
  12. 运行命令 "git commit -m 'new file'" 将文件添加到 repo
  13. 运行命令“git status”,你应该得到“working dir clean”消息
  14. 使用 'cd ..' cd 回到主目录
  15. 在主目录中创建一个符号链接 'ln -s project1 project1.git'
  16. 运行命令“pwd”以获取完整路径
  17. 在我的情况下,完整路径是“/Users/myname/git/project1.git”
  18. 写下完整路径以供以后在 URL 中使用
  19. 退出远程机器

LOCAL MACHINE

本地机器

  1. create a project folder somewhere 'newproj1' with 'mkdir newproj1'
  2. cd into it
  3. run command 'git init'
  4. make an alias to the REMOTE MACHINE
  5. the alias command format is 'git remote add your_alias_here URL'
  6. make sure your URL is correct. This caused me headaches initially
  7. URL = 'ssh://[email protected]/Users/myname/git/project1.git'
  8. after you do 'git remote add alias URL' do 'git remote -v'
  9. the command should respond with a fetch and push line
  10. run cmd 'git pull your_alias master' to get test.php from REMOTE repo
  11. after the command in #10 you should see a nice message.
  12. run command 'git push --set-upstream your_alias master'
  13. after command in 12 you should see nice message
  14. command in #12 sets up REMOTE as the project master (root)
  1. 使用“mkdir newproj1”在“newproj1”的某处创建一个项目文件夹
  2. cd进去
  3. 运行命令'git init'
  4. 为 REMOTE MACHINE 创建别名
  5. 别名命令格式为“git remote add your_alias_here URL”
  6. 确保您的网址正确。这最初让我头疼
  7. URL = 'ssh://[email protected]/Users/myname/git/project1.git'
  8. 执行“git remote add alias URL”后,执行“git remote -v”
  9. 该命令应以 fetch 和 push 行响应
  10. 运行 cmd 'git pull your_alias master' 从远程仓库获取 test.php
  11. 在 #10 中的命令之后,您应该会看到一条不错的消息。
  12. 运行命令'git push --set-upstream your_alias master'
  13. 在 12 中的命令之后,您应该会看到不错的消息
  14. #12 中的命令将 REMOTE 设置为项目主(root)

For me, i learned getting a clean start with a git repo on a LOCAL and REMOTE requires all initial work in a shell first. Then, after the above i was able to easily setup the LOCAL and REMOTE git repos in my IDE and do all the basic git commands using the GUI of the IDE.

对我来说,我学会了在 LOCAL 和 REMOTE 上使用 git repo 获得一个干净的开始,首先需要在 shell 中进行所有初始工作。然后,在上述操作之后,我能够在我的 IDE 中轻松设置 LOCAL 和 REMOTE git repos,并使用 IDE 的 GUI 执行所有基本的 git 命令。

I had difficulty until I started at the remote first, then did the local, and until i opened up all the permissions on remote. In addition, having the exact full path in the URL to the symlink was critical to succeed.

我遇到了困难,直到我首先从远程开始,然后在本地开始,直到我打开远程的所有权限。此外,在指向符号链接的 URL 中拥有准确的完整路径对于成功至关重要。

Again, this all worked on OS X, local and remote machines.

同样,这一切都适用于 OS X、本地和远程机器。

回答by Wolfgang Grinfeld

I had a similar problem when using TFS 2017. I was not able to push or pull GIT repositories. Eventually I reinstalled TFS 2017, making sure that I installed TFS 2017 with an SSH Port different from 22 (in my case, I chose 8022). After that, push and pull became possible against TFS using SSH.

我在使用 TFS 2017 时遇到了类似的问题。我无法推送或拉取 GIT 存储库。最终我重新安装了 TFS 2017,确保我安装的 TFS 2017 的 SSH 端口不同于 22(在我的情况下,我选择了 8022)。之后,可以使用 SSH 对 TFS 进行推拉。

回答by Ruto Collins

It is most likely that you got your repo's SSH URL wrong.

很可能您的存储库的 SSH URL 是错误的。

To confirm, go to your repository on Github and click the clone or download button. Then click the use SSHlink.

要确认,请转到您在 Github 上的存储库,然后单击clone or download button. 然后点击use SSH链接。

ssh link

SSH 链接

Now copy your officialrepo's SSH link. Mine looked like this - [email protected]:borenho/que-ay.git

现在复制您的官方存储库的 SSH 链接。我的看起来像这样 -[email protected]:borenho/que-ay.git

You can now do git remote add origin [email protected]:borenho/que-ay.gitif you didn't have originyet.

git remote add origin [email protected]:borenho/que-ay.git如果你还没有,你现在可以做origin

If you had set originbefore, change it by using git remote set-url origin [email protected]:borenho/que-ay.git

如果您之前设置origin过,请使用更改它git remote set-url origin [email protected]:borenho/que-ay.git

Now push with git push -u origin master

现在推 git push -u origin master

回答by JChen___

I have a similar problem, but now I know the reason.

我有类似的问题,但现在我知道原因了。

After we use git init, we should add a remote repository using

使用后git init,我们应该使用添加一个远程存储库

git remote add name url

Pay attention to the word name, if we change it to origin, then this problem will not happen.

注意这个词name,如果我们把它改成origin,那么这个问题就不会发生了。

Of course, if we change it to py, then using git pull py branchand git push py branchevery time you pull and push something will also be OK.

当然,如果我们改成py,那么每次拉推东西时使用git pull py branchgit push py branch也是可以的。