文章目录
1、连接远程版本库
GitHub上创公共版本库
2、客户端git使用
centos:
yum 安装git客户端
yum install git -y
第一次:创建新目录,切入目录,初始化,添加文件,提交到本地主版本库,关联远程库到本地,推送本地git仓库的内容推送到GitHub仓库,完成本地与远程仓库
mkdir python-test cd python-test/ echo "
python-test" >> README.md
git init Initialized
empty Git repository in /root/python-test/.git/ git add README.md
git commit -m "first commit"
git remote add origin git@github.com:feko2018/python-test.git
git push -u origin master
使用三部曲:添加文件,提交的本地仓库,推到远程仓库
echo aa >aa.txt
git add .
git commit -m "create aa.txt" # git push origin master
需要添加分支自行百度。
错误提示
Warning: Permanently added the RSA host key for IP address ‘52.74.223.119’ to the list of known hosts.
Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists
解决方法
1、添加hosts解析
52.74.223.119 github.com
2、生成公钥,配置到GitHub里面
ssh-keygen
默认回车
cd /root/.ssh/
cat id_rsa.pub
ssh-rsa AAAAB3NzaC1xxABAAABAQC3xxx6uBzeH47mTNsxgv6ZtOI5hGkKH994MhGRUDr7uQmw/8nxQHAErai7ykp4KfJY2IkAKVG4Er54CsyVHTGVYswxxty8Bo3BeYaT3m/OnQeVlN/zx68n9lC7FLlkXgOGI+aPx0Gs244wAM9cz+0BN9VPqvYcEEFKDKMo0ahXoKslw92ZiB0CyEZVJpXiVmFyIhCP3ZMo6ShbaWl root@centos7
复制到GitHub如下图: