我是github上一个组织的所有者,刚刚创建了一个回购并尝试推送,但我遇到了一个问题,它要求我提供我的用户名,尽管我可以SSH很好:

$ ssh -T git@github.com
Hi Celc! You've successfully authenticated, but GitHub does not provide shell access.
$ git add .
$ git commit -m 'first commit'
[master (root-commit) 3f1b963] first commit
 6 files changed, 59 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 main.js
 create mode 100644 package.json
 create mode 100644 readme.markdown
 create mode 100644 views/index.ejs
 create mode 100644 views/layout.ejs
$ git remote add origin https://github.com/WEMP/project-slideshow.git
$ git push -u origin master
Username for 'https://github.com':

我做错了什么?这从来没有发生在我身上,但我最近也升级到git 1.7.10.3。


当前回答

不要使用HTTP,而是使用SSH

改变

https://github.com/WEMP/project-slideshow.git 

to

git@github.com:WEMP/project-slideshow.git

你可以在.git/config文件中完成

其他回答

我也有同样的问题,想知道为什么用https克隆的比特桶回购没有发生。仔细研究一下,我发现BB回购的配置有一个URL,其中包括我的用户名。所以我手动编辑配置我的GH回购像这样,瞧,没有更多的用户名提示。我用的是Windows。

编辑your_repo_dir /。Git /config(记住:.git文件夹是隐藏的)

变化:

https://github.com/WEMP/project-slideshow.git

to:

https://*username*@github.com/WEMP/project-slideshow.git

保存文件。再拉一下测试一下。

正确的方法可能是使用git bash命令来编辑设置,但直接编辑文件似乎不是问题。

因为你使用的是HTTPS方式。HTTPS要求您每次尝试推或拉时都输入您的帐户访问权限,但也有一种方法,称为SSH,它让您告诉git,我给了您这台pc的帐户权限,并且永远不会再问我任何用户访问权限。要使用它,您必须生成SSH密钥,并将其添加到您的Github帐户,只需一次。要做到这一点,您可以遵循以下步骤

如何为Github生成SSH密钥

如果您使用的是HTTPS,请检查以确保URL是正确的。例如:

$ git clone https://github.com/wellle/targets.git
Cloning into 'targets'...
Username for 'https://github.com': ^C

$ git clone https://github.com/wellle/targets.vim.git
Cloning into 'targets.vim'...
remote: Counting objects: 2182, done.
remote: Total 2182 (delta 0), reused 0 (delta 0), pack-reused 2182
Receiving objects: 100% (2182/2182), 595.77 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1044/1044), done.

不要使用HTTP,而是使用SSH

改变

https://github.com/WEMP/project-slideshow.git 

to

git@github.com:WEMP/project-slideshow.git

你可以在.git/config文件中完成

以下是官方给出的答案:

If Git prompts you for a username and password every time you try to interact with GitHub, you're probably using the HTTPS clone URL for your repository. Using an HTTPS remote URL has some advantages: it's easier to set up than SSH, and usually works through strict firewalls and proxies. However, it also prompts you to enter your GitHub credentials every time you pull or push a repository. You can configure Git to store your password for you. If you'd like to set that up, read all about setting up password caching.