博客动态
Hi!欢迎来到Jerry Coding!公众号垃圾分类增加学习功能,关注下面的公众号一起来帮助Jerry学习更多垃圾分类知识吧!
微信扫码

扫一扫关注我

More
关于
New
RSS

Ubuntu下Git的安装与使用

Jerry 2019年6月23日 1106  

1、安装Git:

root@jerryls-site1:~# apt-get install git

2、配置用户名和邮箱

root@jerryls-site1:~# git config --global user.name "exampleusername"
root@jerryls-site1:~# git config --global user.email "examble@xx.com"

3、创建公钥

root@jerryls-site1:~# ssh-keygen -C "example@xx.com" -t rsa

有提示输入的话直接回车就好,最后出现以下提示:

4、GitHub网站配置密钥

密钥文件生成在以下目录,我们需要拷贝id_rsa.pub 文件中所有内容到Github设置中的SSH Key(Settings ---> Personal settings ---> SSH keys)

root@jerryls-site1:~# cd ~/.ssh/
root@jerryls-site1:~/.ssh# ls
authorized_keys  id_rsa  id_rsa.pub
root@jerryls-site1:~/.ssh# 

5、测试链接

输入以下命令得到回显表明链接成功

root@jerryls-site1:~/.ssh# ssh -T git@github.com
Hi DreamerLS1994! You've successfully authenticated, but GitHub does not provide shell access.

6、上传文件夹

找到我们的/home/mysite文件夹,输入git init:

root@jerryls-site1:/home# ls
mysite  webchat
root@jerryls-site1:/home# git init
Initialized empty Git repository in /home/.git/

添加mysite文件夹:

root@jerryls-site1:/home# git add mysite/

输入提交log信息:

root@jerryls-site1:/home# git commit -m '建站历程2、3源码提交'

配置上传路径:

root@jerryls-site1:/home# git remote add origin https://github.com/DreamerLS1994/MySite

上传文件:

root@jerryls-site1:/home# git push origin master

上传完成后就可以在Github看到文件啦:

7、修改后上传文件

修改了下“README”与上传类似:

root@jerryls-site1:/home# git add README 
root@jerryls-site1:/home# git commit -m '修改文件测试'
root@jerryls-site1:/home# git push origin master

8、克隆项目

输入以下命令可以克隆项目:

root@jerryls-site1:/home/test# git clone https://github.com/DreamerLS1994/MySite

 


原创文章,转载请注明出处: https://jerrycoding.com/article/git_guide

微信
支付宝

您尚未登录,暂时无法评论。请先 登录 或者 注册

0 人参与 | 0 条评论