GIT学习 第二弹 {github链接;拉去代码,提交代码}
新建一个空仓库取名为study,打开仓库主界面如下图
无任何明显提示
进入该文件夹,右键单击Git Bash Here菜单项,
1.使用git push origin master
命令将本地仓库的内容与远程仓库同步
2.使用git pull origin master
命令拉取远程仓库的代码到本地,使本地与远程仓库的代码同步
3.使用git remote add origin https://github.com/tanlei1accp/study.git
命令将本地仓库同步到远程的study仓库。然后再使用git push -u origin master命令将本地仓库的内容推送到远程仓库中。
此时这个地方出现了一个错误
解决方案 :
fatal: Not a git repository (or any of the parent directories): .git
提示说没有.git这样一个目录,解决办法如下:
git init就可以了!
$ git push -u origin master
这里出现了一个错误:src refspec master不匹配
不用理会 其他文章有解决方案;
本地仓库使用如下命令初始化:
$ git init
之后使用如下命令添加远程库:
$ git remote add origin git@github.com:hahah/ftpmanage.git
然后使用
$ git push -u origin master
出现如下错误:
error: src refspec master does not match any. error: failed to push
some refs to ‘git@github.com:hahaha/ftpmanage.git’
原因:
本地仓库为空、
解决方法:
新建文件,在提交一次,$ git commit -m "init files"
之后在push过程中出现如下错误:
提示使用 git pull 之后在 push
使用如下命令解决:
这里再次报错了
这些命令做一波
再次运行$ git push -u origin master
成功
大功告成!!!