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

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

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

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

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

相关推荐
小此方21 小时前
「插曲:Git」企业规范篇:DevOps开发模型、Git Flow五类分支设计与测试/预发布/生产环境Bug修复及Hotfix紧急发布流程
git·bug·devops
溪语流沙21 小时前
【Web全栈进阶】JWT无状态认证:签发、校验、刷新
前端·git·python·github
OsDepK1 天前
osgit纯图形化git版本管理工具,多人开发团队协作工具,支持Mac与Windows
git
Madison-No71 天前
Git版本控制工具(一)
git
小小小米粒2 天前
重置本地git
大数据·git·elasticsearch
鶴哥只手遮天2 天前
第 8 章 工作区与检出:unpack-trees 与并行 checkout
git
xing-xing2 天前
git 相关命令总结
git
A-刘晨阳2 天前
GitLab + ArgoCD 实现 Kubernetes GitOps 自动化部署
运维·人工智能·git·kubernetes·自动化·云计算·argocd
ControlRookie2 天前
SyncBridge:一个 CODESYS 工程与 AI 之间工程师级的同步工具
git·ai编程·codesys·工业软件·controlrookie
鬼手点金3 天前
opencode-性能优化建议
java·人工智能·git·自动化·nanogpt