git与github的区别
git是一个版本控制工具,是Linux的上帝Linus写的:Git教程
github是一个用git做版本控制的项目托管平台,是世界程序员的圣地,兲朝想屏蔽,但会引起大陆IT技术的闭关锁国,被强烈反弹后又开放了。
一、用github建立个人博客
(可以注册多个用户吗?)参考:
利用GitHub写博客的几种方式 #讲述了博客分支的概念
如何利用githubpages来搭建自己的blog #讲述了博客分支的概念
1、github提供了pages功能:
1、repo下有两种pages:user pages和project pages,一个账号只有一个user pages,但可以有多个project pages。
2、user pages必须在
master
分支上,其gh-pages
分支是空的,可以用来做个人主页,project pages必须在gh-pages
分支上,其master
分支是空的。3、个人主页URL必须是
https://<username>.github.io
#博客用github.io域名,github.com域名项目URL是
https://<username>.github.io/<projectname>
举例:
比如我的github用户名是greydesign,个人博客地址就是https://greydesgin.github.io问题:我建了一个repo:Asus,也放在了master分支下,可以吗?
2、Hexo配置:
Jekyll + Coding Pages 搭建静态博客
教你在 Coding 上搭建 Hexo 个人博客
Hexo与Jekyll的区别
1、Hexo用 NodeJS,Jekyll用Ruby,Hexo快一个数量级(高并发场景),对于个人网但站差异不大
2、Hexo 是本地生成 html 再上傳,Jekyll 是把原文上傳 github,直接生成博客,也可以在線編輯
3、很多人从Jekyll转向了Hexo
二、其他
可以参考如下指导建立自己的github博客:
我的博客是如何搭建的(github pages + HEXO + 域名绑定)
以下是我建立github博客的具体步骤:
一、注册github,创建github pages,实现域名解析
注意:一般的教程是最后绑定域名,我觉得首先应该在github端完全配置好了,再本地配置hexo。因为hexo的很多错误,其实是github端的问题。
官网网址:github
我的用户名当然是greydesign
啦。建立自己的仓库(repositories)。需要注意的有如下几点:
1、仓库名与目录类型:
如果想实现静态博客,仓库必须与注册名一致,比如我的博客仓库名就必须是greydesign
,而且github pages必须是master
目录(gh-pages
和/docs
目录不行吗?)。
2、通过二级域名访问自己的github pages
通过https://github.com/greydesign/greydesign.github.io可以访问仓库,但无法通过greydesign.github.io访问博客页面,这是因为github pages还没有运行起来(没有主页等文件,是空的)。查看自家的仓库settings
,看到在GitHub Pages
有提示:
GitHub Pages is currently disabled. You must first add content to your repository before you can publish a GitHub Pages site.解决的办法参考:[hexo初探---让写作飞起来](http://www.jianshu.com/p/e7c58f57f60e),选择一个theme即可,现在就可以通过访问`greydesign.github.io/`了(需要注意的是,自动会转向https访问,好棒!)。而网址`https://github.com/greydesign/greydesign.github.io`看到的是页面的仓库文件信息。 ##### 3、绑定顶级域名(因为无法在github上配置自己的https CA证书,最终放弃) 参考:[hexo搭建的Github博客绑定域名](http://www.jianshu.com/p/cea41e5c9b2a),我在万网注册了`zhangqihui.me`,设置CNAME域名解析:
记录类型:CNAME 主机记录:@ 解析线路:默认 记录值:greydesign.github.io TTL:10分钟用`zhangqihui.me`访问,依然会提示404错误:
There isn't a GitHub Pages site here. If you're trying to publish one, [read the full documentation](https://help.github.com/pages/) to learn how to set up GitHub Pages for your repository, organization, or user account.通过ping这两个网址,只想的ip是相同的,为什么还会出错呢?这是因为虽然在域名服务上那里设置了CNAME,但github端还没有设置好。 参考[添加 CNAME 文件到你的存储库中](http://wiki.jikexueyuan.com/project/github-pages-basics/cname-file.html),添加CNAME的master目录中,`create new file`,会开启一个编辑页面,文件名添`CNAME`,内容添`zhangqihui.me`,在页面底部提交。刷新`zhangqihui.me`页面,终于和`greydesign.github.io`一致了。 ##### 4、实现https访问(不要试图用自己的域名,还是无法配置自定义证书的原因) github全站缺省支持https访问,但如果设置了CNAME,就不再支持了。 为了安全起见,也为了自己的博客在搜索引擎中排名靠前,还是需要实现https的。但新的问题出现了,提交`CNAME`前,原来的`greydesign.github.io`会自动转换为https访问,`zhangqihui.me`不会转且显示404错误信息。提交`CNAME`后,`greydesign.github.io`会转向`http://zhangqihui.me`访问,而`zhangqihui.me`会转向不安全的https访问。 github提供二级域名的https访问,但还不支持自定义域名的https配置,放弃自定义域名吧,把github的CNAME文件删除,阿里云的CNAME域名解析也删除掉,老老实实用二级域名也不错。原则:自定义顶级域名实现https访问,只有在VPS上合适,在github或者wordpress上实施并不合适。 需要注意的是,为了实现https,不要用301跳转,因为会被劫持。至于为啥,我不懂! [CloudFlare 的 Flexible SSL](https://hexo.crboy.net/2016/09/cloudflare-flexible-ssl/) [慎用免费HTTPS:看似美好的免费“通用SSL证书”](http://www.freebuf.com/articles/neopoints/45822.html) [Let's Encrypt,免费好用的 HTTPS 证书](https://imququ.com/post/letsencrypt-certificate.html) #### 二、参考[官方教程](https://hexo.io/zh-cn/docs/)安装Hexo(我的常用电脑操作系统是Windows 10): 1、安装Windows版本的git,从[官方](https://git-scm.com/)下载的是`Git-2.13.0-64-bit.exe`,采用缺省设置安装; 2、安装Windows版本的Node.js,从[官方下载](http://www.runoob.com/nodejs/nodejs-install-setup.html)的是`node-v8.0.0-x64.msi`,采用缺省设置安装; 3、打开Git Bash(从开始菜单->Git程序组->Git Bash,或者在桌面,通过鼠标右键Git Bash here打开),只需要使用 npm 即可完成 Hexo 的安装:`npm install -g hexo-cli`
qdmca@DESKTOP-LIANLI MINGW64 ~ $ npm install -g hexo-cli C:\Users\qdmca\AppData\Roaming\npm\hexo -> C:\Users\qdmca\AppData\Roaming\npm\no de_modules\hexo-cli\bin\hexo > fsevents@1.1.1 install C:\Users\qdmca\AppData\Roaming\npm\node_modules\hexo-cl i\node_modules\fsevents > node install > dtrace-provider@0.8.2 install C:\Users\qdmca\AppData\Roaming\npm\node_modules\ hexo-cli\node_modules\dtrace-provider > node scripts/install.js > hexo-util@0.6.0 postinstall C:\Users\qdmca\AppData\Roaming\npm\node_modules\he xo-cli\node_modules\hexo-util > npm run build:highlight > hexo-util@0.6.0 build:highlight C:\Users\qdmca\AppData\Roaming\npm\node_module s\hexo-cli\node_modules\hexo-util > node scripts/build_highlight_alias.js > highlight_alias.json added 221 packages in 27.329s qdmca@DESKTOP-LIANLI MINGW64 ~ $
三、建站
在windows下开启命令行界面,新建c:\Hexo
目录
>cd \ C:\>mkdir Hexo c:\>cd Hexo c:\Hexo > hexo init greydesign #在c:\Hexo\目录下生成一个子目录greydesign,具体操作如下一个代码框 C:\Hexo>cd greydesign C:\Hexo\greydesign>npm install up to date in 1.827s C:\Hexo\greydesign>
C:\Hexo>hexo init greydesign INFO Cloning hexo-starter to C:\Hexo\greydesign Cloning into 'C:\Hexo\greydesign'... remote: Counting objects: 53, done. remote: Total 53 (delta 0), reused 0 (delta 0), pack-reused 53 Unpacking objects: 100% (53/53), done. Submodule 'themes/landscape' (https://github.com/hexojs/hexo-theme-landscape.git) registered for path 'themes/landscape' Cloning into 'C:/Hexo/greydesign/themes/landscape'... remote: Counting objects: 781, done. remote: Compressing objects: 100% (6/6), done. remote: Total 781 (delta 0), reused 1 (delta 0), pack-reused 775 Receiving objects: 100% (781/781), 2.54 MiB | 778.00 KiB/s, done. Resolving deltas: 100% (397/397), done. Submodule path 'themes/landscape': checked out 'decdc2d9956776cbe95420ae94bac87e22468d38' [32mINFO [39m Install dependencies ��Ϣ: ���ṩ��ģʽ���ҵ��ļ��� npm WARN deprecated swig@1.4.2: This package is no longer maintained npm WARN prefer global marked@0.3.6 should be installed with -g > fsevents@1.1.1 install C:\Hexo\greydesign\node_modules\fsevents > node install > dtrace-provider@0.8.2 install C:\Hexo\greydesign\node_modules\dtrace-provider > node scripts/install.js > hexo-util@0.6.0 postinstall C:\Hexo\greydesign\node_modules\hexo-util > npm run build:highlight > hexo-util@0.6.0 build:highlight C:\Hexo\greydesign\node_modules\hexo-util > node scripts/build_highlight_alias.js > highlight_alias.json npm notice created a lockfile as package-lock.json. You should commit this file. added 440 packages in 31.308s INFO Start blogging with Hexo! C:\Hexo>修改`_config.yml`文件
deploy: type:github repo:https://github.com/greydesign/greydesign.github.io.git branch:master
四、发布:
C:\Hexo>cd greydesign
C:\Hexo\greydesign>hexo s
(node:7432) [DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.
INFO Start processing
INFO Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
INFO Bye!
终止批处理操作吗(Y/N)? y
C:\Hexo\greydesign>hexo clean
(node:6376) [DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.
INFO Deleted database.
C:\Hexo\greydesign>hexo g
(node:4860) [DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.
INFO Start processing
INFO Files loaded in 222 ms
INFO Generated: index.html
INFO Generated: archives/index.html
INFO Generated: fancybox/fancybox_loading@2x.gif
INFO Generated: fancybox/jquery.fancybox.css
INFO Generated: fancybox/blank.gif
INFO Generated: fancybox/fancybox_loading.gif
INFO Generated: fancybox/jquery.fancybox.js
INFO Generated: fancybox/jquery.fancybox.pack.js
INFO Generated: fancybox/fancybox_sprite@2x.png
INFO Generated: fancybox/fancybox_sprite.png
INFO Generated: fancybox/fancybox_overlay.png
INFO Generated: archives/2017/index.html
INFO Generated: archives/2017/06/index.html
INFO Generated: css/fonts/FontAwesome.otf
INFO Generated: fancybox/helpers/jquery.fancybox-buttons.js
INFO Generated: js/script.js
INFO Generated: css/style.css
INFO Generated: fancybox/helpers/jquery.fancybox-buttons.css
INFO Generated: fancybox/helpers/jquery.fancybox-media.js
INFO Generated: fancybox/helpers/jquery.fancybox-thumbs.css
INFO Generated: css/fonts/fontawesome-webfont.eot
INFO Generated: css/fonts/fontawesome-webfont.woff
INFO Generated: fancybox/helpers/jquery.fancybox-thumbs.js
INFO Generated: fancybox/helpers/fancybox_buttons.png
INFO Generated: css/fonts/fontawesome-webfont.ttf
INFO Generated: 2017/06/11/hello-world/index.html
INFO Generated: css/images/banner.jpg
INFO Generated: css/fonts/fontawesome-webfont.svg
INFO 28 files generated in 624 ms
C:\Hexo\greydesign>npm install hexo-deployer-git –save
added 2 packages in 6.372s
C:\Hexo\greydesign>hexo d
(node:10200) [DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated. #啥意思,发布了吗?如何看git个人博客?
C:\Hexo\greydesign>
打开git bash,生成密钥(使用hexo搭建github.io博客(一)):
qdmca@DESKTOP-LIANLI MINGW64 ~
$ ls -al ~/.ssh
ls: cannot access ‘/c/Users/qdmca/.ssh’: No such file or directory
qdmca@DESKTOP-LIANLI MINGW64 ~
$ ssh-keygen -t rsa -b 4096 -C “qdmcad@gmail.com“
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/qdmca/.ssh/id_rsa):
Created directory ‘/c/Users/qdmca/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/qdmca/.ssh/id_rsa.
Your public key has been saved in /c/Users/qdmca/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:P6XxYI/iJncOqOEqfrd8p9HGSmHhUz323urRagqJ4pI qdmcad@gmail.com
The key’s randomart image is:
+—[RSA 4096]—-+
| |
| . |
| . . + |
| . o . o |
| =S + .. |
| ..o.O. o |
| o..+o= oo o |
|. Eo++o+o. .+ |
|.oo.=+o+o..++ |
+—-[SHA256]—–+
qdmca@DESKTOP-LIANLI MINGW64 ~
$
手把手教你使用Hexo + Github Pages搭建个人独立博客
使用Hexo搭建个人博客(基于hexo3.0)
史上最详细的Hexo博客搭建图文教程
python : send mobi to my email
六、在Coding Pages上托管Hexo博客(国内的服务,自定义域名收费,还有备案等麻烦,没有尝试就放弃了,放点静态页面,做做测试罢了)
1、在官网注册greydesign用户;
附:非程序员的Git生活
git用来做版本控制,比svn多了一个缓存区。
我有一个大胆的想法:用来进行结构设计的协同设计与版本控制,当然也可以在工业设计师中推广。
七、Gitlab
公开 repo 放 github,私有 repo 放码云,公司 repo 放公司内网 gitlab
大家除了 Github 还用啥国内的 Git 服务?