解决: Cannot load information for github.com

问题在共享项目至idea时候出现:
I am getting this error while sharing on GithHub in Intellije IDEA : Cannot load information for github.com/: Request response: Access to this site has been restricted. If you believe this is an error, please contact https://support.github.com. · community · Discussion #128045

 



方案一:更新idea
参考:I am getting this error while sharing on GithHub in Intellije IDEA : Cannot load information for github.com/: Request response: Access to this site has been restricted. If you believe this is an error, please contact https://support.github.com. · community · Discussion #128045


方案二:使用git提交
PC使用了WSL,所以直接在WSL配置git(详见:随笔:)
每次都执行一大堆命令太麻烦了直接上批处理:
为了完善Windows批处理脚本,以便在执行推送之前先显示git status的输出,并且能够同时推送到GitHub和Gitee(假设你已经为这两个远程仓库配置了不同的名称,如origin对应GitHub,gitee对应Gitee):

  

@echo off  
chcp 65001 > nul  setlocal enabledelayedexpansion
echo 正在检查当前Git状态... wsl bash -c "cd /mnt/d/SoftwareFile/IntelliJIDEProjects/javalearn && git status" echo. set /p continue="是否继续推送?(Y/N): " if /i "!continue!"=="Y" ( echo 正在添加所有更改到暂存区... wsl bash -c "cd /mnt/d/SoftwareFile/IntelliJIDEProjects/javalearn && git add ." echo 准备提交更改... set /p commitMessage="请输入提交信息: " if "%commitMessage%"=="" ( echo 提交信息不能为空,推送操作已取消。 goto end ) wsl bash -c "cd /mnt/d/IntelliJIDEProjects/xxx && git commit -m '%commitMessage%'" echo 正在拉取远程更改以避免冲突... 需要修改为自己的项目路径 wsl bash -c "cd /mnt/d/SoftwareFile/IntelliJIDEProjects/xxx && git pull origin main && git pull gitee main" echo 正在推送到GitHub... wsl bash -c "cd /mnt/d/SoftwareFile/IntelliJIDEProjects/xxx && git push origin main" echo 正在推送到Gitee... wsl bash -c "cd /mnt/d/SoftwareFile/IntelliJIDEProjects/xxx && git push gitee main" echo 推送完成! ) else ( echo 推送操作已取消。 ) :end echo. echo 按任意键退出... pause > nul endlocal

 

 

 

  1. 脚本中使用了pause > nul来暂停执行,直到用户按任意键继续。> nul是为了避免在命令行中显示“请按任意键继续...”的消息。

  2. 我添加了一个set /p命令来让用户输入提交信息。如果提交信息为空,则脚本会取消推送操作。

  3. 在拉取远程更改时,我假设你的主分支名为main。如果你的分支名不同(如master),请相应地更改它。

  4. 脚本同时拉取origingiteemain分支,这可能会导致一些不必要的合并,特别是如果它们之间存在差异的话。通常,你可能只需要拉取你计划从中推送更改的远程仓库。但是,为了安全起见,这里我保留了同时拉取两个远程仓库的操作。

  5. 如果你的Git配置(如用户名、邮箱)已经设置好,并且远程仓库的URL也配置好了,这个脚本应该能够正常工作。

  6. 如果你的Git仓库配置了不同的分支名或远程仓库名,请相应地更改脚本中的origingiteemain

  7. 运行此脚本时,请确保你的WSL环境已经启动,并且你的Windows用户有权访问/mnt/d/SoftwareFile/IntelliJIDEProjects/javalearn目录。

  8. 如果你在推送时遇到任何权限问题,请确保你的WSL用户有权访问Git仓库,并且你的SSH密钥已经正确配置在GitHub和Gitee上。

posted @ 2024-07-21 18:33  def_Class  阅读(219)  评论(0编辑  收藏  举报