Git和Github的基本使用

来源:互联网 发布:移动光纤网络机房在哪 编辑:程序博客网 时间:2024/05/29 14:10

本文首发链接
查看我的个人博客:https://hubinqiang.com


1. 安装 Git

sudo apt-get updatesudo apt-get install git

2. 配置 Git

配置

git config --global user.name "HuBinqiang"git config --global user.email "hubinqiang@126.com"

查看

git config --list

编辑

nano ~/.gitconfig

3. 配置Github

创建公钥

ssh-keygen -C 'hubinqiang@126.com' -t rsa

上传公钥

在 github.com 的界面中 选择右上角的 Account Settings,然后选择 SSH Public Keys ,选择新加。
Title 可以随便命名,Key 的内容拷贝自 ~/.ssh/id_rsa.pub 中的内容,完成后,可以再使用

ssh -v git@github.com

进行测试。看到下面的信息表示验证成功。

Exit status 1

4. 使用Git

创建git 的根目录

mkdir -p ~/git/testcd ~/git/test

创建测试文件

touch REAME

初始化该目录

git init

新增文件到git 注意后面的 . 表示当前目录

git add .

提交所有文件

git commit -m "This is message." -a

提交到Github(首次)

git remote add origin https://github.com/HuBinqiang/Algorithms.git

查看

git remote -v

提交到Github

git push origin master
0 0