小白 创建Git 仓库笔记

2018-02-27  本文已影响0人  peterMenghuan
  1. 首先在github 上创建新的仓库,具体可见 (不再多说)
http://wiki.jikexueyuan.com/project/github-basics/creat-new-repo.html
  1. 然后在本地想作为仓库的目录下 使用
git init

命令 初始化本地仓库

  1. 将项目里所有文件加到本地的仓库,使用以下命令:
  git add .  //注意还有一个小圆点
  git commit -m "some message for this project."
  1. 然后将github上的项目pull下来
  git pull https://github.com/youraccount/yourproject.git
  1. 为版本库添加名为origin的远程版本库。
git remote add origin (你的远程仓库地址,
例如: https://github.com/youraccount/yourproject.git)

  1. 执行推送命令,完成GitHub版本库的初始化。注意命令行中的-u参数,在推送成功后自动建立本地分支与远程版本库分支的追踪
  git push -u origin master

注: 如果遇到github上的版本里有readme文件和本地版本冲突,下面给出冲突原因:

Username for 'https://github.com': shiren1118
Password for 'https://shiren1118@github.com': 
To https://github.com/shiren1118/iOS_code_agile.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/shiren1118/iOS_code_agile.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.

命令行终极解决方式:

git push -u origin master -f 
上一篇下一篇

猜你喜欢

热点阅读