Git和Github的基本使用

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


1. 安装 Git

sudo apt-get update
sudo apt-get install git

2. 配置 Git

配置

git config --global user.name "HuBinqiang"
git config --global user.email "[email protected]"

查看

git config --list

编辑

nano ~/.gitconfig

3. 配置Github

创建公钥

ssh-keygen -C '[email protected]' -t rsa

上传公钥

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

ssh -v [email protected]

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

Exit status 1

4. 使用Git

创建git 的根目录

mkdir -p ~/git/test
cd ~/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

猜你喜欢

转载自blog.csdn.net/hubinqiang/article/details/54414875
今日推荐