github关联本地创建的git库


本地创建项目文件夹

例如: jekyll-document-to-pdf

初始化git仓库

$ cd jekyll-document-to-pdf
$ git init

添加改动文件 (或者添加所有文件)

$ git add .

本地提交 git代码库

$ git commit -m "初次提交"
$ git push origin master

如果没有关联远程库, 直接push, 则会报错

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

github上创建 代码库

创建代码库

关联本地库 (本地代码库添加远程地址)

$ git remote add origin https://github.com/itaken/jekyll-document-to-pdf.git

push推送, 即可同步到github中.

$ git push -u origin master

提交代码

如果远程新建了文件,可以使用git fetch origin,同步自己的修改, 然后git pull origin master拉取远程文件, 最后提交.


参考文档


Author: Itaken
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Itaken !
  TOC目录