本地仓库使用如下命令初始化:
$ git init
之后使用如下命令添加远程库:
$ git remote add origin git@github.com:gitee用户名/仓库名.git
然后使用
$ git push -u origin master
出现如下错误:
error: src refspec master does not match any
error: failed to push some refs to 'gitee.com:gitee用户名/仓库名.git'
引起该错误的原因是:目录中没有文件,空目录是不能提交上去的
解决方法:
touch README
git add README
git commit -m 'first commit'
最后执行$ git push -u origin master
以上是出现的错误~~~~~~~~~~~
下面的错误本人暂未出现~~~~~~~~~~~
如果出现这个错误:Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
可能是暂存区没有文件,通过git add操作可以添加到暂存区以便commit。
运行 $git add .成功把文件存到暂存区
接下来继续运行$git commit -m 'first commit'将暂存区的代码提交到本地仓库
最后成功push到GitHub上面 $git push origin master
如果push中出现如下错误:: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
.这可能是是由于你的git地址采用了ssh方式,切换为https方式
在终端中输入:
$ git remote set-url origin https://github.com/YourUserName/YatouTest00123.git
然后再push一下
$git push -u origin master