git 无法推送到 github 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5486143/
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
Cannot push to github repo
提问by Abhijeet Rastogi
My repo: https://[email protected]/shadyabhi/learnajax.git
我的仓库:https://[email protected]/shadyabhi/learnajax.git
shadyabhi@archlinux-N210 ~/github/learnajax $ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://[email protected]/shadyabhi/learnajax.git
fetch = +refs/heads/*:refs/remotes/origin/*
shadyabhi@archlinux-N210 ~/github/learnajax $ git config -l
user.name=shadyabhi
[email protected]
merge.tool=vimdiff
github.token=1095de7027bVVVV01cfAAAAAa5fc8f6
color.ui=auto
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://[email protected]/shadyabhi/learnajax.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
shadyabhi@archlinux-N210 ~/github/learnajax $ git push -u origin master
Password:
fatal: Authentication failed
shadyabhi@archlinux-N210 ~/github/learnajax $
Now, I cant push into my repo. I have checked the github.token its the same as my Account Settings. Ofcoarse, I am entering the right password but I get this error.
现在,我无法进入我的回购。我已经检查了 github.token,它与我的帐户设置相同。Ofcoarse,我输入了正确的密码,但出现此错误。
采纳答案by Abhijeet Rastogi
There is some issue (if using https) if username contains "some" special characters.
如果用户名包含“某些”特殊字符,则会出现一些问题(如果使用 https)。
回答by Kelley Kavanaugh
I was having a similar issue pushing my origin with the correct user and password. It turned out that I had turned on 2-factor Authentication and had forgotten. If you have 2-factor Authentication enabled you will need to create an application specific password to push your repo. https://help.github.com/articles/creating-an-access-token-for-command-line-use
我有一个类似的问题,使用正确的用户和密码推送我的来源。原来是我开启了 2-factor Authentication 并且忘记了。如果您启用了 2 因素身份验证,您将需要创建一个应用程序特定密码来推送您的存储库。https://help.github.com/articles/creating-an-access-token-for-command-line-use
回答by Mark Longair
As I understand it, github.token
(and github.user
) aren't used by git HTTP transport - they're only there for other tools that use GitHub's API, such as GitX and GitNub.
据我了解,github.token
(和github.user
)没有被 git HTTP 传输使用——它们只用于其他使用 GitHub API 的工具,例如 GitX 和 GitNub。
I think the "Authentication failed" error mustbe due to you entering the wrong password. (This should be your GitHub password rather than the password to your SSH private key.)
我认为“身份验证失败”错误一定是由于您输入了错误的密码。(这应该是您的 GitHub 密码,而不是您的 SSH 私钥的密码。)
回答by t7ko
I have hit the same problem just now. Apparently, when you use git in command line, it wants you to enter the access token instead of password. This is really weird, but it works.
我刚才遇到了同样的问题。显然,当您在命令行中使用 git 时,它希望您输入访问令牌而不是密码。这真的很奇怪,但它有效。
$ git push origin HEAD
Username for 'https://github.com': <--- your username here
Password for 'https://[email protected]': <--- access token here O_O
PS: This is the instruction on creating token: https://help.github.com/articles/creating-an-access-token-for-command-line-use
PS:这是创建令牌的说明:https: //help.github.com/articles/creating-an-access-token-for-command-line-use
回答by HPi
I had just same problem as previously described. Passwords with #
, ¤
or "
didn't seem to work, whatever I tried.
我遇到了与之前描述的相同的问题。无论我尝试过什么#
,带有¤
或 的密码"
似乎都不起作用。
Seems to be more or less similar problem as with Microsoft Office 365 portal, where you can't use ex. ¤
character in password, if you are going to use mobile devices as well.
似乎与 Microsoft Office 365 门户或多或少类似的问题,您不能使用 ex。¤
密码中的字符,如果您也打算使用移动设备。
Github login works fine with all passwords, in web... but using whatever client, it doesn't.
Github 登录适用于所有密码,在网络中......但使用任何客户端,它都没有。
回答by user673207
If your password contains special characters, git push
won't work in Terminal. My workaround is open up emacs
and do git push
inside eshell
.
如果您的密码包含特殊字符,git push
将无法在终端中使用。我的解决方法是 open up emacs
and do git push
inside eshell
。
回答by Peter T.
if your username or password has special characters, you can replace it with the encoded
for example, if your password is "test@2010", you will write it as "test%402010" and the config command will be like this
git config remote.origin.url https://{username}:test%[email protected]/{repo_username}/{repo_name}.git
如果您的用户名或密码有特殊字符,您可以将其替换为编码例如,如果您的密码是“test@2010”,则将其写为“test%402010”,配置命令将是这样的
git config remote.origin.url https://{username}:test%[email protected]/{repo_username}/{repo_name}.git