致命:似乎不是 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
fatal: does not appear to be a git repository
提问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 One
account, 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/config
file 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
远程机器
- Login to your account
- Create a master dir for all projects 'mkdir git'
- chmod 775 git then cd into it
- make a project folder 'mkdir project1'
- chmod 777 project1 then cd into it
- run command 'git init' to make the repo
- this creates a .git dir. do command 'chmod 777 .git' then cd into it
- run command 'chmod 777 *' to make all files in .git 777 mod
- cd back out to myproject1 (cd ..)
- setup a test file in the new repo w/command 'touch test.php'
- add it to the repo staging area with command 'git add test.php'
- run command "git commit -m 'new file'" to add file to repo
- run command 'git status' and you should get "working dir clean" msg
- cd back to master dir with 'cd ..'
- in the master dir make a symlink 'ln -s project1 project1.git'
- run command 'pwd' to get full path
- in my case the full path was "/Users/myname/git/project1.git'
- write down the full path for later use in URL
- exit from the REMOTE MACHINE
- 登录到您的帐户
- 为所有项目“mkdir git”创建一个主目录
- chmod 775 git 然后 cd 进去
- 创建一个项目文件夹“mkdir project1”
- chmod 777 project1 然后 cd 进去
- 运行命令 'git init' 来制作 repo
- 这将创建一个 .git 目录。执行命令 'chmod 777 .git' 然后 cd 进入
- 运行命令 'chmod 777 *' 以生成 .git 777 mod 中的所有文件
- cd 回到 myproject1 (cd ..)
- 在带有命令“touch test.php”的新仓库中设置一个测试文件
- 使用命令 'git add test.php' 将其添加到 repo 暂存区
- 运行命令 "git commit -m 'new file'" 将文件添加到 repo
- 运行命令“git status”,你应该得到“working dir clean”消息
- 使用 'cd ..' cd 回到主目录
- 在主目录中创建一个符号链接 'ln -s project1 project1.git'
- 运行命令“pwd”以获取完整路径
- 在我的情况下,完整路径是“/Users/myname/git/project1.git”
- 写下完整路径以供以后在 URL 中使用
- 退出远程机器
LOCAL MACHINE
本地机器
- create a project folder somewhere 'newproj1' with 'mkdir newproj1'
- cd into it
- run command 'git init'
- make an alias to the REMOTE MACHINE
- the alias command format is 'git remote add your_alias_here URL'
- make sure your URL is correct. This caused me headaches initially
- URL = 'ssh://[email protected]/Users/myname/git/project1.git'
- after you do 'git remote add alias URL' do 'git remote -v'
- the command should respond with a fetch and push line
- run cmd 'git pull your_alias master' to get test.php from REMOTE repo
- after the command in #10 you should see a nice message.
- run command 'git push --set-upstream your_alias master'
- after command in 12 you should see nice message
- command in #12 sets up REMOTE as the project master (root)
- 使用“mkdir newproj1”在“newproj1”的某处创建一个项目文件夹
- cd进去
- 运行命令'git init'
- 为 REMOTE MACHINE 创建别名
- 别名命令格式为“git remote add your_alias_here URL”
- 确保您的网址正确。这最初让我头疼
- URL = 'ssh://[email protected]/Users/myname/git/project1.git'
- 执行“git remote add alias URL”后,执行“git remote -v”
- 该命令应以 fetch 和 push 行响应
- 运行 cmd 'git pull your_alias master' 从远程仓库获取 test.php
- 在 #10 中的命令之后,您应该会看到一条不错的消息。
- 运行命令'git push --set-upstream your_alias master'
- 在 12 中的命令之后,您应该会看到不错的消息
- #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 SSH
link.
要确认,请转到您在 Github 上的存储库,然后单击clone or download button
. 然后点击use 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.git
if you didn't have origin
yet.
git remote add origin [email protected]:borenho/que-ay.git
如果你还没有,你现在可以做origin
。
If you had set origin
before, 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 branch
and git push py branch
every time you pull and push something will also be OK.
当然,如果我们改成py
,那么每次拉推东西时使用git pull py branch
和git push py branch
也是可以的。