首页 > 代码库 > git学习笔记(四)

git学习笔记(四)

http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013752340242354807e192f02a44359908df8a5643103a000

 

本地和远程github 相关联

现在本地新建一个git仓库

git init

与远程相关联

git remote add origin XXX.git

推送本地文件到远程

git push -u origin master

这边出现的 一个问题

To https://github.com/HelloKing/Professional-JavaScript-3.git
! [rejected]        master -> master (fetch first)
error: failed to push some refs to ‘https://github.com/HelloKing/Professional-Ja
vaScript-3.git‘
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull ...‘) before pushing again.
hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.

原因是在github上新建项目时候加了个read.me文件,远程仓库存在本地仓库不存在的文件,所以需要进行整合远程变更

http://blog.csdn.net/ispeller/article/details/22183961

 

解决方案

git pull origin master (git pull)指令学习

git commit file

然后进行push

git push -u origin master

git学习笔记(四)