前期准备:在github拥有账号,本地安装git;
第一步、在github上创建一个工程;
第二步、使用git创建用户名及邮箱:
git config --global user.name "姓名"
git config --global user.email "邮箱"
第三步、生成秘钥与公钥
ssh-keygen -t rsa
Enter file in which to save the key (/c/Users/167/.ssh/id_rsa)://这里指定生成文件的名称,可以不填直接默认
Enter passphrase (empty for no passphrase)://如果为空 则默认使用私钥进行连接
Enter same passphrase again:
秘钥名称:
id_rsa
id_rsa.pub
第四步、将公钥导入github
第五步、将github代码拉到本地
git clone 你自己的github上的地址;
git相关命令操作:
1、git init //初始化
(出现:fatal: Not a git repository (or any of the parent directories): .git错误一般是没有初始化git)
2、将本地文件上传到远程服务器
git add -A(或者.) //将所有的文件添加到暂存区
git commit -m "注释" //将暂存区的文件提交到版本库
git push -u origin master // 把本地仓库的文件推送到远程仓库
git pull origin master // 将远程仓库拉到本地仓库
使用git clone及git push 发现太慢了,可以使用码云gitee;