目录
二、git clone 出现错误 Could not resolve host: github.com问题
一、生成 SSH 密钥
1、输入指令获取密匙
1)ssh-keygen -t rsa -C "[email protected]" //邮箱用自己的邮箱
2)输入回车
3)输入回车
2、生成的密匙在id_rsa.pub文件里
cd /c/Users/*****/.ssh //生成的密匙显示路径,先跳入.ssh文件夹下
cat id_rsa.pub //输入该指令查看密匙,复制一下
3、进入gitlab上方搜索SSH,进入后粘贴并保存即可
二、git clone 出现错误 Could not resolve host: github.com问题
1、解析域名。错误的原因可能是gitlab.com
域名没有被主机解析
ping gitlab.com //ping一下该网络得到解析域名地址
2、添加域名。
在C盘windows/System32/drivers/etc文件夹下【hosts】文件内,用notepad++打开
172.65.251.78 gitlab.com //文件在末尾添加该函数,域名用自己ping的域名替换
文件保存后解决问题,再次克隆就能够成功。
三、小乌龟设置完远端URL后同步文件出现错误提示
TortoiseGit错误 - Could not get all refs. libgit2 returned: corrupted loose reference file
解决方法:
rm -fr .git //删除.git文件
git init //初始化git
git remote add origin your-git-remote-url //URL要修改为自己的 如下图提示
git fetch //同步远程库
git reset --hard origin/master //复位master分支
git branch --set-upstream-to=origin/master master //切换到仓库主分支master
四、git创建推送步骤
1、创建文件夹并建立库
cp -r /d/sdk/* /d/git/ //从一个文件里复制代码到本地
2、设置git远端
3、直接进行推送
五、小乌龟推送失败
1、问题:remote: GitLab: You are not allowed to force push code to a protected branch on this project.
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
原因:由于当前用户没有push权限,就是[master]代码默认是被保护的,所以进行push的时候会报错,去掉保护权限即可。
解决方法:
2、问题:Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes
更新被拒绝,因为您当前分支的尖端落后。提示:它的远程对应物。 集成远程更改
解决方法:
git pull origin master --allow-unrelated-histories //拉取的时候忽略历史提交
//操作完后点x关闭指令界面
git push origin master:master //制定推送到master
上述方案没有结局问题,还是出现错误,采用创建新分支的方法解决问题
git branch [name] //创建新的分支
git push origin [name] //重新拉取
3、问题:git pull提示 warning: redirecting to https://igit.**.com/**/**.git/ Already up to date.
解决方法:
git remote remove origin //第一步:删除现有的origin地址
git remote add origin https://igit.**.com/**/**.git/ //第二步:重新绑定origin地址
六、小乌龟不显示对号图标
解决方法:
1、小乌龟设置中开启图标覆盖
2、注册表中修改git顺序
①Windows + R 运行命令框
②输入 regedit +回车 查看注册表
③根据路径查看小乌龟相关文件的顺序 如果没有排在最前面按下图操作修改HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers
3、重启运行explorer.exe进程
①先结束运行explorer.exe
②开启explorer.exe进程
七、git追踪下载指定版本代码
1、获取当前最新版本代码
git clone http://****************/v3.4
2、查找提交的所有版本log
//进入该版本内 输入指令:git log
root@123:/mnt/hgfs/ESP8266_RTOS_SDK# git log
3、下载自己需要的版本
//在当前目录下输入指令:
git checkout 0360263b55fd88a00d41d3fc6d0b955ef5b88000
八、从git上拉取代码出错
fatal: unable to access 'https://github.com/espressif/ESP8266_RTOS_SDK.git/': Failed to connect to 127.0.0.1 port 1080 after 2093 ms: Connection refused
git config --global --list //查看当前用户配置
git config --global --edit //取消代理把HTTP网址连接127.0.0.1 相关删除
后面持续完善。。。