linux命令行下载github文件,Linux命令行下使用GitHub

Linux命令行下使用GitHub

1.注册github账号

2.创建ssh密钥

cd ~

ssh-keygen -t rsa -C your_email@example.com

1

2

cd~

ssh-keygen-trsa-Cyour_email@example.com

545abbc2eadf0b21cc54326c255bdd92.gif

会在~/.ssh/下生成id_rsa.pub文件,在github网站上的SSH and GPG keys —>New SSH Keys,标题随便写,可以写计算机的名字,将id_rsa.pub里面的内容粘贴key里,最后点击Add SSH Key。

3.打开终端

ssh -T git@github.com

1

ssh-Tgit@github.com

这一步如果提示Permission denied (publickey),就执行ssh-keygen -t rsa -b 4096 -C "your_email@example.com"重新产生key,出现一下提示,说明以正常连接到github

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

1

Higanchunsheng!You'vesuccessfullyauthenticated,butGitHubdoesnotprovideshellaccess.

545abbc2eadf0b21cc54326c255bdd92.gif

4.在github上创建仓库

上传代码按照这个步骤:

git init #初始化

git add . #初始化本地仓库

git commit -m "first commit" #加注释,并提交到本地仓库

git remote add origin https://github.com/xxxx/test.git #连接远程仓库

git push -u origin master #将本地仓库的东西提交到master分支下

1

2

3

4

5

gitinit#初始化

gitadd.#初始化本地仓库

gitcommit-m"first commit"#加注释,并提交到本地仓库

gitremoteaddoriginhttps://github.com/xxxx/test.git #连接远程仓库

gitpush-uoriginmaster#将本地仓库的东西提交到master分支下

545abbc2eadf0b21cc54326c255bdd92.gif

5.下载代码

master分支:

git clone https://github.com/xxxx/test.git #xxxx为用户名

1

gitclonehttps://github.com/xxxx/test.git #xxxx为用户名

545abbc2eadf0b21cc54326c255bdd92.gif

包含子分支:

git clone --recursive https://github.com/xxxx/test.git

1

gitclone--recursivehttps://github.com/xxxx/test.git

6.常见问题

(1)提示错误:fatal: remote origin already exists.解决办法:

git remote rm origin

1

gitremotermorigin

(2)git未初始化

***Please tell me who you are.

Run

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

1

2

3

4

***Pleasetellmewhoyouare.

Run

gitconfig--globaluser.email"you@example.com"

gitconfig--globaluser.name"Your Name"

545abbc2eadf0b21cc54326c255bdd92.gif

解决办法:

git config --global user.name "your_email"

config --global user.email your_email@example.com

1

2

gitconfig--globaluser.name"your_email"

config--globaluser.emailyour_email@example.com

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 你可以在 Linux 系统中使用命令行工具下载 Github 上的文件,具体方法如下: 1. 安装 Git:在终端中输入 sudo apt-get install git。 2. 克隆 Github 仓库:输入 git clone [仓库地址]。 例如: ``` $ git clone https://github.com/username/repository.git ``` 3. 进入仓库文件夹:cd [仓库名称]。 4. 更新文件:输入 git pull。 这样就可以在本地下载 Github 上的文件了。 ### 回答2: 要在Linux下载GitHub文件,可以使用Git工具或者直接使用浏览器下载。 一、使用Git工具下载GitHub文件: 1. 打开终端,进入要保存文件的目录。 2. 使用命令`git clone [仓库链接]`来克隆GitHub仓库到本地。例如,`git clone https://github.com/username/repository.git`。 3. 输入GitHub用户名和密码,如果使用SSH密钥可以省略此步骤。 4. 克隆完成后,在本地目录中即可找到GitHub仓库的文件和目录。 二、通过浏览器下载GitHub文件: 1. 使用浏览器打开GitHub仓库的链接。 2. 在仓库中浏览文件和目录,选择要下载文件。 3. 点击文件名或者“Download”按钮,即可开始下载文件。 4. 文件将保存到浏览器默认下载路径,可以在浏览器的下载管理中找到。 无论使用哪种方法,下载完成后你就可以在本地进行使用、编辑或者运行下载文件。 ### 回答3: 要在Linux下载GitHub文件,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了Git工具。你可以在终端中输入以下命令来检查是否已经安装了Git: ``` git --version ``` 如果未安装,你可以使用适合你的发行版的包管理器来安装Git。 2. 打开终端,并进入你想要下载文件的目录。 3. 复制GitHub仓库的URL地址。你可以在仓库页面的右上角找到 "Clone or download" 按钮,点击按钮后会弹出URL地址。 4. 在终端中输入以下命令来克隆整个GitHub仓库到本地: ``` git clone <GitHub仓库的URL地址> ``` 例如,如果你想要克隆名为 "myproject" 的仓库,可以输入以下命令: ``` git clone https://github.com/your-username/myproject.git ``` 5. 当克隆完成后,你可以在当前目录中看到一个新的文件夹,其中包含了整个GitHub仓库的文件。 注意:如果你只想下载单个文件而不是整个仓库,可以使用以下方法: 1. 打开终端,并进入你想要下载文件的目录。 2. 复制GitHub单个文件的URL地址。你可以在文件所在的页面中找到 "Download" 按钮,点击按钮后会弹出URL地址。 3. 在终端中输入以下命令来下载文件: ``` wget <文件的URL地址> ``` 例如,如果你想下载名为 "myfile.txt" 的文件,可以输入以下命令: ``` wget https://github.com/your-username/myproject/myfile.txt ``` 这样,你就可以在Linux上很方便地下载GitHub文件了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值