找不到 Git 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10255543/
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
Git repository not found
提问by Michele
I'm trying to use Git for the first time.
我第一次尝试使用 Git。
I did everything that github instructions said to do, but when I got to:
我做了 github 指令说要做的所有事情,但是当我开始时:
git push -u origin master
I typed:
我输入:
/Users/name/Documents/Xcode.app/Contents/Developer/usr/bin/git push -u origin master
And got the error:
并得到错误:
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
I also tried to set my git path to the above since it says git isn't found, but the path didn't work. So I've just been typing the whole thing out. When I did sudo find / -name git
, it came up with the above directory for git, and also some other directories that I wasn't sure about, such as
我还尝试将我的 git 路径设置为上述内容,因为它说找不到 git,但该路径不起作用。所以我只是把整个事情都打出来了。当我这样做时sudo find / -name git
,它想出了上面的 git 目录,以及一些我不确定的其他目录,例如
- /Applications/Xcode.app/Contents/Developer/usr/bin/git
- /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
- /Applications/Xcode.app/Contents/Developer/usr/share/git-core/python/git_remote_helpers/git
- /Users/name/Documents/Xcode.app/Contents/Developer/usr/share/git-core/python/git_remote_helpers/git
- /Applications/Xcode.app/Contents/Developer/usr/bin/git
- /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
- /Applications/Xcode.app/Contents/Developer/usr/share/git-core/python/git_remote_helpers/git
- /Users/name/Documents/Xcode.app/Contents/Developer/usr/share/git-core/python/git_remote_helpers/git
and the one that I used:
和我使用的那个:
- /Users/name/Documents/Xcode.app/Contents/Developer/usr/bin/git
- /Users/name/Documents/Xcode.app/Contents/Developer/usr/bin/git
I saw that all of the other commands to set up a git repository seemed to work ok.
Other commands to set up included
我看到设置 git 存储库的所有其他命令似乎都可以正常工作。
要设置的其他命令包括
mkdir fbPic2
cd fbPic2
<path to git>/git init
touch README
<path to git>/git add README
<path to git>/git commit -m 'first commit'
<path to git>/git remote add origin [email protected]:michcleary/fbPic2.git
<path to git>/git push -u origin master #didn't work
I tried to look for .git/config
but can't find it.
我试图寻找,.git/config
但找不到。
I hope someone out there knows about this. It says that I need to get Git installed to do a Facebook app in the tutorial. I have a Mac Mini with Lion installed.
我希望有人知道这件事。它说我需要安装 Git 才能在教程中创建 Facebook 应用程序。我有一台装有 Lion 的 Mac Mini。
回答by GoZoner
Absolute first step is to get Xcode to install the 'command line tools'. Doing that will get the tools into /usr/bin - which is already in your PATH. Go to "Xcode" :: "Preferences" :: "Downloads" :: "Components" where there should be an install "Command Line Tools". If there isn't, go to "Xcode" :: "Open Developer Tool" :: "More Developer Tools" and download the most recent command line tools. Now, 'git' will be in your path. Should also be that 'git help ' works too!
绝对的第一步是让 Xcode 安装“命令行工具”。这样做将使工具进入 /usr/bin - 它已经在您的 PATH 中。转到“Xcode”::“首选项”::“下载”::“组件”,其中应该安装“命令行工具”。如果没有,请转到“Xcode”::“Open Developer Tool”::“More Developer Tools”并下载最新的命令行工具。现在,'git' 将在您的路径中。也应该是 'git help ' 也能工作!
Now configure git with (as suggested by @johnsyweb):
现在使用(如@johnsyweb 建议的那样)配置 git:
git config --global user.name "full name"
git config --global user.email "email address"
and for GitHub:
对于 GitHub:
git config --global github.user "github username"
git config --global github.token "github token"
where you will need to follow the GitHub directions to get your token. You'll also need to carefully follow the GitHub SSH instructions. After the above 'git config' commands you will have a ~/.gitconfig file ready to go.
您需要按照 GitHub 说明获取令牌。您还需要仔细遵循 GitHub SSH 说明。在上面的 'git config' 命令之后,你将有一个 ~/.gitconfig 文件准备好了。
Presumably you have created a GitHub repository already. If not, you must. [It doesn't look like you have a public repository yet.] After creating one, the easiest approach to getting a local repository setup is simply:
想必您已经创建了一个 GitHub 存储库。如果没有,你必须。[看起来您还没有公共存储库。] 创建一个后,获取本地存储库设置的最简单方法很简单:
git clone [email protected]:michcleary/fbPic2 # cut and past the URI from the GitHub page after creating a repo
cd fbPic2
echo "more stuff" >> README.md
git add
git commit -m 'stuff'
git push
Done!
完毕!
回答by bj97301
I spend a couple of weeks on this and came to the conclusion that the git app on mac uses the https remote repository url but when using the term you need the ssh url. To fix this I clicked the settings tab in the github app then pasted in the ssh url from the github site for my repo.
我花了几个星期的时间,得出的结论是,mac 上的 git 应用程序使用 https 远程存储库 url,但是在使用该术语时,您需要 ssh url。为了解决这个问题,我单击了 github 应用程序中的设置选项卡,然后将 github 站点中的 ssh url 粘贴到我的存储库中。
回答by suman
In my case the user did not have appropriate permissions. After I used the user with proper permissions the error vanished.
在我的情况下,用户没有适当的权限。在我使用具有适当权限的用户后,错误消失了。
回答by Johnsyweb
Firstly I suggest you add <path to git>
to your PATH
environment variable. You will probably do this by editing ${HOME}/.bashrc
and adding:
首先我建议你添加<path to git>
到你的PATH
环境变量中。您可能会通过编辑${HOME}/.bashrc
和添加来做到这一点:
export PATH=${PATH}:<path to git>
The remote repository certainly exists at https://github.com/michcleary/.
远程存储库肯定存在于https://github.com/michcleary/。
It looks like you haven't configured Git locally with your name and email address, which is why you can't see a Git configuration file.
看起来您没有使用您的姓名和电子邮件地址在本地配置 Git,这就是您看不到 Git 配置文件的原因。
There are a number of ways of doing this, but I suggest you follow the instructions from GitHub's "Set your user name, email and GitHub token"page to set these up for all Git instances on your local machine:
有多种方法可以做到这一点,但我建议您按照 GitHub 的“设置您的用户名、电子邮件和 GitHub 令牌”页面中的说明为本地计算机上的所有 Git 实例设置这些:
$ git config --global user.name "Firstname Lastname"
$ git config --global user.email "[email protected]"
This will add these values to ${HOME}/.gitconfig
.
这会将这些值添加到${HOME}/.gitconfig
.
Repository-specific values will exist in /path/to/fbPic2/.git/config
(.git
is a hidden directory).
特定于存储库的值将存在于/path/to/fbPic2/.git/config
(.git
是一个隐藏目录) 中。
You should set these configuration items beforeissuing any other git
commands such as init
or commit
or push
.
您应该在发出任何其他git
命令(例如init
或commit
或 )之前设置这些配置项push
。
I also recommend checking out GitHub's "SSH Issues"page as that is often helpful for first-time GitHub users.
我还建议查看 GitHub 的“SSH 问题”页面,因为这通常对首次使用 GitHub 的用户很有帮助。