git的使用学习笔记3---关于项目分支创建克隆拉取推送

 一、创建项目

1.打开官网

2.填写相关内容

查看新创建的项目

3.选择方式

 4.在git上新建文件夹

1)克隆:

 mkdir workspace

将代码克隆到本地,取本地配置的.ssh的文件

git clone git@github.com:bingtubao/AutoTest.git 

2)推送

编辑一个文件

vi test.txt

注意:vi模式下,先输入i为编辑模式,在按esc切换到命令模式,然后:wq保存退出

git status 查看状态

git add 文件名         追踪文件

git commit -m "提交信息"    添加本次提交的文件

git push    推送到github网站

查看推送成果,在github上看

命令总结:

git init

git add text.txt

git commit -m "提交信息"

git remote add origin https://github.com/bingtubao/AutoTest.git

git push -u origin master

3)拉取

git  pull   拉取

5.遇到问题总结:

1)The authenticity of host 'github.com (13.229.188.59)' can't be established.

问题原因:

本地仓库和远程的SSH不匹配

解决办法:

a:

Are you sure you want to continue connecting (yes/no)?时,选择yes

b:

 ls -al ~/.ssh

c:

ssh-keygen -t rsa -C "github用户名",按三次回车

 d:

cat ~/.ssh/id_rsa.pub生成新的SSH

e:

登陆github,点击头像-settings-new SSH,复制新生成的SSH

然后再次正常拉取即可。

 2)fatal: not a git repository (or any of the parent directories): .git

原因:没有.git这样一个目录

解决办法:

git init

再次输入命令正常创建

原文地址:https://www.cnblogs.com/huanlfu/p/11336008.html