1.初始化仓库:git init
2.在github上创建一个项目
3.将GitHub上的路径拷贝下来:
git remote add origin [email protected]:(github上的账号名)/(项目名).git
4.跟踪新文件(将内容从工作目录添加到暂存区:git add .(注意git add后加上空格在加上 .)
5.提交暂存区的指定文件到仓库区: git commit -m"first"
6.将本地代码推送到仓库:git push origin master
注:如果执行git push origin master后报:
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
可能出现以下下原因:
(1)客户端与服务端未生成 ssh key
(2)客户端与服务端的ssh key不匹配
为解决以上问题,我们需要重新生成一次ssh key ,并重新配置一下GitHub账户即可。
解决步骤:
1.生成新的SSH key:
如果是客户端与服务端未生成ssh key,那么直接使用:
ssh-keygen -t rsa -C "[email protected]"
生成新的rsa密钥即可。
如果是