知了小站 - IT人的小站 - Git教程 2022-07-21T17:56:00+08:00 Typecho https://www.ydyno.com/feed/atom/tag/git/ <![CDATA[记 Git - Permission denied (publickey) 问题]]> https://www.ydyno.com/archives/1636.html 2022-07-21T17:56:00+08:00 2022-07-21T17:56:00+08:00 知了小站 https://www.ydyno.com 最近在 Centos 9 stream 上使用 ssh-keygen -t rsa -C "email" 生成密钥,在 coding 添加公钥后 clone 代码出现如下问题

git@e.coding.net: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

将密钥复制到本地电脑上进行测试,发现可以成功 clone 项目。

通过搜索发现 csdn 没有一个答案能解决问题(全是重复的文章),最后在国外网站找到了解决办法

解决方案

不使用 rsa 算法生成密钥,使用更安全的 ECDSA 或 ED25519 生成

ssh-keygen -t ed25519 -C "email"

coding 重新添加后,成功 clone 了项目。感觉可能是 OpenSSH 版本问题,有时间再测测看。

参考:https://confluence.atlassian.com/bitbucketserverkb/ssh-rsa-key-rejected-with-message-no-mutual-signature-algorithm-1026057701.html

]]>
<![CDATA[解决 ssh: connect to host github.com port 22: Connection timed out]]> https://www.ydyno.com/archives/1510.html 2022-04-18T21:50:00+08:00 2022-04-18T21:50:00+08:00 知了小站 https://www.ydyno.com 问题引入

当我在国内 Linux 机器上安装好 Git 环境后,将 github 代码克隆到 Linux 服务器出现了如下问题

[root@ydyno ~]# git clone git@github.com:elunez/**.git
正克隆到 '**'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方法

进入 ~/.ssh 查看是否缺少 config 配置文件,如果缺少该配置文件那么使用如下命令创建

# 创建并写入文件数据
vi ~/.ssh/config
# 写入如下数据,User 填入注册时的邮箱
Host github.com  
User xxxxx@xx.com  
Hostname ssh.github.com  
PreferredAuthentications publickey  
IdentityFile ~/.ssh/id_rsa  
Port 443

修改文件权限

sudo chmod 600 config

再次 clone 发现已经没问题了

[root@ydyno ~]# git clone git@github.com:elunez/**.git
正克隆到 '**'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
^C收对象中:  35% (5/14), 2.67 MiB | 544.00 KiB/s 

参考:https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port#enabling-ssh-connections-over-https

]]>
<![CDATA[Github文件加速平台分享]]> https://www.ydyno.com/archives/1383.html 2021-11-10T16:34:00+08:00 2021-11-10T16:34:00+08:00 知了小站 https://www.ydyno.com 前言

受防火墙的影响Github国内访问质量一直不太行,这个时候我们可以使用Github加速平台,提高国内访问Github速度。

平台支持 raw.githubusercontent.com , gist.github.com , gist.githubusercontent.com 文件加速下载

可以查看 搭建教程 进行自行搭建,如果不想折腾的可以使用我搭建的成品站 GitHub 文件加速

l25i04wf.png

使用说明

支持终端命令行 git clone , wget , curl 等工具下载

支持终端命令行 git clone, wget, curl 等工具下载.

git clone https://slink.ltd/https://github.com/elunez/3DCEList.git

wget https://slink.ltd/https://github.com/elunez/3DCEList/archive/refs/heads/master.zip

curl -O https://slink.ltd/https://github.com/elunez/3DCEList/archive/refs/heads/master.zip

注意:不支持项目文件夹,不支持 SSH Key 方式 git clone 下载

输入示例

分支源码:https://github.com/elunez/3DCEList/archive/refs/heads/master.zip

Raw 文件:https://raw.githubusercontent.com/elunez/3DCEList/master/index.html

Releases 源码:https://github.com/NginxProxyManager/nginx-proxy-manager/archive/v2.9.16.tar.gz

Releases 文件:https://github.com/NginxProxyManager/nginx-proxy-manager/archive/refs/tags/v2.9.16.tar.gz
]]>
<![CDATA[GIT 常用命令整理]]> https://www.ydyno.com/archives/git-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E6%95%B4%E7%90%86.html 2019-01-07T12:33:00+08:00 2019-01-07T12:33:00+08:00 知了小站 https://www.ydyno.com master : 默认开发分支; origin : 默认远程版本库

初始化操作

$ git config -global user.name <name>  #设置提交者名字
$ git config -global user.email <email>  #设置提交者邮箱
$ git config -global core.editor <editor>  #设置默认文本编辑器
$ git config -global merge.tool <tool>  #设置解决合并冲突时差异分析工具
$ git config -list  #检查已有的配置信息

创建新版本库

$ git clone <url>  #克隆远程版本库
$ git init  #初始化本地版本库

修改和提交

$ git add .  #添加所有改动过的文件
$ git add <file>  #添加指定的文件
$ git mv <old> <new> #文件重命名
$ git rm <file>  #删除文件
$ git rm -cached <file>  #停止跟踪文件但不删除
$ git commit -m <file> #提交指定文件
$ git commit -m “commit message”  #提交所有更新过的文件
$ git commit -amend  #修改最后一次提交
$ git commit -C HEAD -a -amend  #增补提交(不会产生新的提交历史纪录)

查看提交历史

$ git log  #查看提交历史
$ git log -p <file>  #查看指定文件的提交历史
$ git blame <file>  #以列表方式查看指定文件的提交历史
$ gitk  #查看当前分支历史纪录
$ gitk <branch> #查看某分支历史纪录
$ gitk --all  #查看所有分支历史纪录
$ git branch -v  #每个分支最后的提交
$ git status  #查看当前状态
$ git diff  #查看变更内容

撤消操作

$ git reset -hard HEAD  #撤消工作目录中所有未提交文件的修改内容
$ git checkout HEAD <file1> <file2>  #撤消指定的未提交文件的
修改内容
$ git checkout HEAD. #撤消所有文件
$ git revert <commit>  #撤消指定的提交

分支与标签

$ git branch  #显示所有本地分支
$ git checkout <branch/tagname>  #切换到指定分支或标签
$ git branch <new-branch>  #创建新分支
$ git branch -d <branch>  #删除本地分支
$ git tag  #列出所有本地标签
$ git tag <tagname>  #基于最新提交创建标签
$ git tag -d <tagname>  #删除标签

合并与衍合

$ git merge <branch>  #合并指定分支到当前分支
$ git rebase <branch>  #衍合指定分支到当前分支

远程操作

$ git remote -v  #查看远程版本库信息
$ git remote show <remote>  #查看指定远程版本库信息
$ git remote add <remote> <url>  #添加远程版本库
$ git fetch <remote>  #从远程库获取代码
$ git pull <remote> <branch>  #下载代码及快速合并
$ git push <remote> <branch>  #上传代码及快速合并
$ git push <remote> : <branch>/<tagname>  #删除### 远程分支或标签
$ git push -tags  #上传所有标签
]]>