github下载的常用操作

本文详细介绍GitHub上常见的操作步骤,包括克隆项目及其子模块、获取特定版本代码、查看提交历史等,并提供了解决网络问题的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

github常用下载操作

1. github克隆时一并下载子模块

2. github克隆某个tag的内容

3. github查看当前分支的commit记录

4. github查看当前的commit号码

5. github克隆某个commit的内容(要同一个bench)

6. github.com[0: 20.205.243.166]: errno=Connection timed out 的解决

7. fatal: unable to access 'https://git.qemu.org/git/capstone.git/': Empty reply from server

8. 如果出现一直都无法处理的网络问题,直接把主目录下的gitconfig文件删掉,重新配置git环境及代理

9. github 出现以下报错

若出现 ssh: connect to host github.com port 22: Connection timed out ,按以下方法解决


github常用下载操作

1. github克隆时一并下载子模块

# 一起下载
git clone --recursive https://github.com/Cambricon/CNStream
# 下载了项目之后(存在嵌套的子模块)
git submodule sync --recursive
git submodule update --init --recursive
# 或
git submodule sync --recursive
git submodule init
git submodule update

2. github克隆某个tag的内容

命令:

git clone --branch [tags标签] [git地址] 或者 git clone -b [tags标签] [git地址]

例如:

git clone -b 1.4.1 https://github.com/jumpserver/coco.git

git clone -b 1.4.1 --single-branch https://github.com/jumpserver/coco.git

git clone --recursive -b 1.4.1 https://github.com/jumpserver/coco.git

3. github查看当前分支的commit记录

git log

4. github查看当前的commit号码

git rev-parse HEAD
# 或者
git rev-parse --short HEAD

5. github克隆某个commit的内容(要同一个bench)

# 找到当前commit所在的bench或者tag
git clone -b [tag标志] https://github.com/aa/bb.git
# 然后切换
git checkout 2342dsfsdfs2
# 新建分支保存更改
git checkout -b branch

6. github.com[0: 20.205.243.166]: errno=Connection timed out 的解决

git config --global url."https://".insteadOf git://

7. fatal: unable to access 'https://git.qemu.org/git/capstone.git/': Empty reply from server

wangmin@wangmin-G3-3579:~/sel4/qemu$ git config --global http.proxy
socks5://127.0.0.1:7891
wangmin@wangmin-G3-3579:~/sel4/qemu$ git config --global --unset http.proxy

8. 如果出现一直都无法处理的网络问题,直接把主目录下的gitconfig文件删掉,重新配置git环境及代理

fatal:unable to connect to xxxx,  xxx[0:20.218.253.93]  errno=连接超时

如果仍然出现连接超时,使用下列代码,注意只使用一次即可(看配置文件):

git config --global url.https://github.com/.insteadOf git://github.com/
git config --global url."https://".insteadOf git://

9. github 出现以下报错

error: RPC failed; curl 18 Transferred a partial file3.00 KiB/s
error: 3075 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

可以尝试使用ssh进行clone。

1. 使用下面的命令创建 ssh 密钥,输完之后一直回车就行

ssh-keygen -t rsa -C "your_email@youremail.com"

密钥存储在 .ssh目录下的`id_rsa.pub`文件中(windows在:c\user\你的用户名    Linux在 ~/.ssh)

2. 添加生成的密钥到github,登陆你的github帐户。点击你的头像,然后 Settings -> 左栏点击 SSH and GPG keys -> 点击 New SSH key

3. 然后你复制上面的公钥内容,粘贴进“Key”文本域内。 title域,自己随便起个名字。

4. 完成以后,验证下这个key是不是正常工作:

ssh -T git@github.com

如果,看到:

Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access.

说明成功

若出现 ssh: connect to host github.com port 22: Connection timed out ,按以下方法解决

1. 在C盘——用户——你的主机名文件夹中找到.ssh文件夹;(此前配置SSH时会生成该文件夹)
2. 在.ssh文件夹中新建文件 config,不带后缀(可以新建文本文档,去掉.txt后缀),输入以下内容,保存后即可

Host github.com
User YourEmail(你的邮箱)
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443


参考:git下载指定版本的代码_M_Eve的博客-优快云博客_git clone 指定版本

git子模块的相关操作:

https://worthsen.blog.youkuaiyun.com/article/details/123288706

Github子模块(submodule)使用介绍_cain-won的博客-优快云博客_github submodule​​​​​​
git操作是出现Username for 'https://github.com':的验证问题-优快云博客https://www.cnblogs.com/tsalita/p/16181711.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值