前提
ssh -T git@github.com 命令连接正常;
git clone、git pull 正常,github页面 `Settings/SSH and GPG keys` 确认已添加过本地ssh公钥。
注:git clone 出现类似问题的,可以考虑先移步git clone出现 fatal: unable to access 'https://github.com/...'的解决办法(亲测有效)_明天也要加油鸭的博客-CSDN博客
$ ssh -T git@github.com
Hi birdflyi! You've successfully authenticated, but GitHub does not provide shell access.
问题
git push 失败,提示fatal: 发送请求时出错,并报告不再支持密码认证方式,需要使用personal access token替代密码认证方式(然而前面已确认github页面添加过本地的ssh公钥)。
Adan@Adan-PC MINGW64 /e/gitRepo/Research-Methods-of-Cross-Science (main)
$ git push --set-upstream origin main
fatal: 发送请求时出错。
fatal: 请求被中止: 未能创建 SSL/TLS 安全通道。
fatal: 发送请求时出错。
fatal: 请求被中止: 未能创建 SSL/TLS 安全通道。
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/birdflyi/Research-Methods-of-Cross-Science/'
remote报错:2021年8月13日,移除了对密码验证方式的支持。请改用个人访问令牌。
官方的解释:https://github.blog/changelog/2021-08-12-git-password-authentication-is-shutting-down/
已有相关博客解释说明此变化,并给出了配置github上的ssh Keys的方法[1]:GitHub不再支持密码验证解决方案:SSH免密与Token登录配置 - 爱码网
此博客还包含使用令牌的好处说明:GitHub不再支持密码验证解决方案:SSH免密与Token登录配置 - 爱码网
特殊情况的特征在于:git remote -v 显示配置的url是http或https协议的,而配置的ssh需要使用git@github.com形式的ssh协议url。
Adan@Adan-PC MINGW64 /e/gitRepo/Research-Methods-of-Cross-Science (main)
$ git remote -v
origin https://github.com/birdflyi/Research-Methods-of-Cross-Science (fetch)
origin https://github.com/birdflyi/Research-Methods-of-Cross-Science (push)
综上,github的ssh Keys配置(详见[1]不再赘述)没有问题的情况下,将remote的url改成ssh所需的git@github.com形式即可。
即:
$ git remote remove origin
$ git remote add origin git@github.com:birdflyi/Research-Methods-of-Cross-Science
实践中会有一些额外的操作才能使用默认的 git push 命令:
Adan@Adan-PC MINGW64 /e/gitRepo/Research-Methods-of-Cross-Science (main)
$ git remote -v
origin https://github.com/birdflyi/Research-Methods-of-Cross-Science (fetch)
origin https://github.com/birdflyi/Research-Methods-of-Cross-Science (push)
Adan@Adan-PC MINGW64 /e/gitRepo/Research-Methods-of-Cross-Science (main)
$ git remote remove origin
Adan@Adan-PC MINGW64 /e/gitRepo/Research-Methods-of-Cross-Science (main)
$ git remote add origin git@github.com:birdflyi/Research-Methods-of-Cross-Science
Adan@Adan-PC MINGW64 /e/gitRepo/Research-Methods-of-Cross-Science (main)
$ git remote -v
origin git@github.com:birdflyi/Research-Methods-of-Cross-Science (fetch)
origin git@github.com:birdflyi/Research-Methods-of-Cross-Science (push)
Adan@Adan-PC MINGW64 /e/gitRepo/Research-Methods-of-Cross-Science (main)
$ git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
Adan@Adan-PC MINGW64 /e/gitRepo/Research-Methods-of-Cross-Science (main)
$ git push --set-upstream origin HEAD:main
Everything up-to-date
branch 'main' set up to track 'origin/main'.
Adan@Adan-PC MINGW64 /e/gitRepo/Research-Methods-of-Cross-Science (main)
$ git push
Everything up-to-date
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
这是在Ruby中设置默认值的常用方法:classQuietByDefaultdefinitialize(opts={})@verbose=opts[:verbose]endend这是一个容易落入的陷阱:classVerboseNoMatterWhatdefinitialize(opts={})@verbose=opts[:verbose]||trueendend正确的做法是:classVerboseByDefaultdefinitialize(opts={})@verbose=opts.include?(:verbose)?opts[:verbose]:trueendend编写Verb
在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送
我最近决定从我的系统中卸载RVM。在thispage提出的一些论点说服我:实际上,我的决定是,我根本不想担心Ruby的多个版本。我只想使用1.9.2-p290版本而不用担心其他任何事情。但是,当我在我的Mac上运行ruby--version时,它告诉我我的版本是1.8.7。我四处寻找如何简单地从我的Mac上卸载这个Ruby,但奇怪的是我没有找到任何东西。似乎唯一想卸载Ruby的人运行linux,而使用Mac的每个人都推荐RVM。如何从我的Mac上卸载Ruby1.8.7?我想升级到1.9.2-p290版本,并且我希望我的系统上只有一个版本。 最佳答案
我的工作要求我为某些测试自动生成电子邮件。我一直在四处寻找,但未能找到可以快速实现的合理解决方案。它需要在outlook而不是其他邮件服务器中,因为我们有一些奇怪的身份验证规则,我们需要保存草稿而不是仅仅发送邮件的选项。显然win32ole可以做到这一点,但我找不到任何相当简单的例子。 最佳答案 假设存储了Outlook凭据并且您设置为自动登录到Outlook,WIN32OLE可以很好地完成此操作:require'win32ole'outlook=WIN32OLE.new('Outlook.Application')message=
我正在尝试找到一种方法来规范化字符串以将其作为文件名传递。到目前为止我有这个:my_string.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'').downcase.gsub(/[^a-z]/,'_')但第一个问题:-字符。我猜这个方法还有更多问题。我不控制名称,名称字符串可以有重音符、空格和特殊字符。我想删除所有这些,用相应的字母('é'=>'e')替换重音符号,并将其余的替换为'_'字符。名字是这样的:“Prélèvements-常规”“健康证”...我希望它们像一个没有空格/特殊字符的文件名:“prelevements_routin