GitHub 遇到的小问题

首先建立项目,XXX

按照github上的命令行提示:

(1)终端上将项目克隆到本地,git clone https://github.com/username/projectname.git

  (2)touch README.md

  (3)git init:

    【Initialized empty Git repository in /home/song/code/.git/】

(4)git add README.md

  (5)git commit -m "first commit"

  (6)cd 项目

     git remote add origin https://github.com/username/projectname.git

     git push -u origin master

        按照提示输入用户名密码

 (7) 把代码托到项目文件夹中,git add .

        git commit -m "balabala"

        git  push originmaster,产生如下错误:

【! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/chuachua1080/natp_server.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.】

 

解决方法:git pull

    git push origin master

   问题就解决了『

google后,发现是由于远程仓库中代码版本与本地不一致冲突导致的。

解决:

git pull

再自动merge或手动merge冲突

再次git push

成功解决问题。

参考文章:

 

posted @ 2013-12-02 19:23  画家与我  阅读(188)  评论(0编辑  收藏  举报