我正尝试使用个人访问令牌对GitHub进行身份验证。在github的帮助文件中,它声明使用curl方法进行身份验证( help.github/articles/creating-an-access-token-for-command-line-use )。我已经尝试过,但仍然无法推送到GitHub。请注意,我试图从未认证的服务器(Travis-CI)推送。
config --global user.emailemailaddress@yahoo git config --global user.nameusername curl -u用户名:< MYTOKEN> github/username/ol3-1.git git clone --branch = gh-pages github/username/ol3-1.git gh-pages cd gh-pages mkdir buildtest cd buildtest touch asdf.asdf git add -f。 git commit -mTravis build $ TRAVIS_BUILD_NUMBER push to gh-pages git push -fq origin gh-pages这段代码会导致错误:
remote:匿名访问scuzzlebuzzle / ol3-1.git拒绝。
致命:< https://认证失败github/scuzzlebuzzle/ol3-1.git/ '
谢谢
curl 命令是完全错误的,您应该使用以下命令: $ b $ b curl -H'Authorization:token< MYTOKEN>'...除此之外,它并不授权您的计算机克隆存储库,但实际上它是私有的(但是,请注意,它不是)。 do是以下内容:
git clone https:// scuzzlebuzzle:< MYTOKEN> ; @ github / scuzzlebuzzle / ol3-1.git --branch = gh-pages gh-pages这会将您的凭据添加到克隆存储库时创建的远程。然而,不幸的是,你无法控制Travis如何克隆你的仓库,所以你必须像这样编辑远程。
#克隆后 cd gh-pages git remote rm origin git remote add origin https:// scuzzlebuzzle:< MYTOKEN> @ github / scuzzlebuzzle / ol3-1.git这将修复您的项目以使用内置凭证的远程计算机。
I am trying to authenticate with GitHub using a personal access token. In the help files at github, it states to use the curl method to authenticate (help.github/articles/creating-an-access-token-for-command-line-use). I have tried this, but still I cannot push to GitHub. Please note, I am trying to push from an unauthenticated server (Travis-CI).
cd $HOME git config --global user.email "emailaddress@yahoo" git config --global user.name "username" curl -u "username:<MYTOKEN>" github/username/ol3-1.git git clone --branch=gh-pages github/username/ol3-1.git gh-pages cd gh-pages mkdir buildtest cd buildtest touch asdf.asdf git add -f . git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages" git push -fq origin gh-pagesThis code causes the errors:
remote: Anonymous access to scuzzlebuzzle/ol3-1.git denied.
fatal: Authentication failed for 'github/scuzzlebuzzle/ol3-1.git/'"
Thanks
解决方案Your curl command is entirely wrong. You should be using the following
curl -H 'Authorization: token <MYTOKEN>' ...That aside, that doesn't authorize your computer to clone the repository if in fact it is private. (Taking a look, however, indicates that it is not.) What you would normally do is the following:
git clone scuzzlebuzzle:<MYTOKEN>@github/scuzzlebuzzle/ol3-1.git --branch=gh-pages gh-pagesThat will add your credentials to the remote created when cloning the repository. Unfortunately, however, you have no control over how Travis clones your repository, so you have to edit the remote like so.
# After cloning cd gh-pages git remote rm origin git remote add origin scuzzlebuzzle:<MYTOKEN>@github/scuzzlebuzzle/ol3-1.gitThat will fix your project to use a remote with credentials built in.
更多推荐
使用令牌对GitHub进行身份验证
发布评论