码迷,mamicode.com
首页 > 其他好文 > 详细

Git下从本地添加项目到远程仓库遇到的问题

时间:2015-08-31 23:29:20      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:

在GitHub上新建一个bookstore仓库,然后初始化后,仓库中只存在README.MD文件。

在本地新建Git仓库:

  1、mkdir bookstore

  2、cd bookstore

  3、git init

  4、将文件添加进去(file)

  5、git add file1 file2 file...

  6、git commit -m "add files"

  7、git remote add origin git@github.com:hahaha/project.git

  8、git push -u origin master

  在这里,出现了错误提示:

  error: failed to push some refs to ‘git@github.com:michaelliao/learngit.git‘

  hint: Updates were rejected because the tip of your current branch is behind

  hint: its remote counterpart. Merge the remote changes (e.g. ‘git pull‘)

  hint: before pushing again.

  hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.

  这里提示推送失败,因为在GitHub上初始化了一个README.MD文件,远程仓库中的文件比本地的要新,所以要使用git pull要把最新的文件抓下来,与本地的文件合并之后在提交。

  9、git pull

  提示错误:

  remote: Counting objects: 5, done.

  remote: Compressing objects: 100% (2/2), done.

  remote: Total 3 (delta 0), reused 3 (delta 0)

  Unpacking objects: 100% (3/3), done.

  From github.com:michaelliao/learngit

     fc38031..291bea8  dev        -> origin/master

  There is no tracking information for the current branch.

  Please specify which branch you want to merge with.

  See git-pull(1) for details

     git pull <remote> <branch>

  原因是没有指定本地master和远程origin/master的连接。

  10、设置连接

  $ git branch --set-upstream master origin/master

  11、git pull

  12、然后提交

  git commit -m "merge README.MD"

  13、git push -u origin master

  完成本地上传远程仓库。

Git下从本地添加项目到远程仓库遇到的问题

标签:

原文地址:http://www.cnblogs.com/helloarcher/p/4774254.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!