Github vim 操作

程序员应该没有不知道github的吧?

今天来说下把自己项目提交到github的过程
有两种方法

  1. 下载桌面管理工具,github-desktop
    执行命令 brew cask install github-desktop即可安装
  2. 手动添加,使用命令行

今天说的就是使用命令行上传

  1. 首先,你得一个现成的项目

  2. 然后开始上传

    PS:Mac默认安装过git了

    这里以刚刚写的testLinkSyntax工程来举例
    https://github.com/WooNoah/testLinkSyntax.git

本地配置

  • cd ~/Desktop/testLinkSyntax ---cd到要上传的项目文件夹内
  • git init ---初始化git
  • git add * ---把整个项目添加进本地仓库
  • git commit -m 'Add project to the repository' ---提交,-m 后是提交的Log Message

然后编辑远程服务器上的配置

  • https://github.com登录
  • New repository
  • 设置好名字,然后获取到远程仓库的URL

在回到本地,将本地的仓库关联到github上

  • git remote add origin https://github.com/WooNoah/testLinkSyntax.git
  • git pull origin master把远程仓库的数据同步到本地(注1)
  • git push -u origin master 把更新后的工程传上github <期间会让输入UsernamePassword>

本人git使用也不是很熟练,所以好多命令也是现查的。还请各位多多指教。

注1

操作合并pull指令的时候,出现的问题fatal: refusing to merge unrelated histories如何去解决

  1. 我们在github上新建了一个远程仓库,勾选了一并生成README文件
  2. 然后pull,出现refusing to merge unrelated histories,无法pull。
  3. 因为git pull,这句代码是在git 2.9.2版本发生的,最新的版本需要添加--allow-unrelated-histories

也就是说:
假如我们的源是origin,分支是master,那么我们 需要这样写git pull origin master --allow-unrelated-histories就OK了

你可能感兴趣的:(Github vim 操作)