解决: 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上。

相关推荐
jayaccc1 天前
Git命令大全:从入门到精通
大数据·git·elasticsearch
论迹1 天前
【Git】-- Git安装 & 卸载(ubuntu)
git·ubuntu·elasticsearch
论迹1 天前
【Git】-- Git基本操作
git·ubuntu
wxr06161 天前
GIT学习
git·学习
猫头虎1 天前
2026最新|GitHub 启用双因素身份验证 2FA 教程:TOTP.app 一键生成动态验证码(新手小白图文实操)
git·开源·gitlab·github·开源软件·开源协议·gitcode
爱学英语的程序员1 天前
让AI 帮我做了个个人博客(附提示词!)
人工智能·git·vue·github·node·个人博客
liu****2 天前
git工具
git·python·算法·机器学习·计算机基础
wxr06162 天前
git无法克隆
git
cooldream20092 天前
Git 拒绝推送(Push Rejected)问题全解析与解决方案实战指南
git
wxr06162 天前
GIT无法push
git·gitee