如何在M$系统中管理 Gitcafe 的Pages 内容发布?

msysgit-logo.png(PNG 图像,220x256 像素) 为杯具的 M$ 环境,一键式提供了 git 环境!

那么如何使用 gitcafe 提供的 pages 服务?

整体思路,参考:

Gitcafe 中发布 Pages 也是同样的过程:

  • 注册帐号,部署 SSH公匙
  • 将帐号加入对应仓库的成员列表
    • 当然,也可以走 github 倡议的 Frok->code->Pull Requests->Pull+merged 流程
  • 在本地 clone 出仓库复本,进行写作
    • 注意: 必须在约定的 gitcafe-pages 分支中建立 Jekll 工程,才会被当成 Pages 业务被编译!
  • 解决可能的冲突后,pushGitcafe 完成自动编译,发布

###强调一下思路

  • gitcafe-pages 本质是在服务端的 jekyll <http://jekyllrb.com/>_ 服务
  • 所以,我们在本地写文章时,只需要记住:
    • 所有文章组织在 _posts 目录中
    • 使用的文件名格式为:
2012-12-19-usage-msysgit-make-pages.md
|   |  |    |                      +- 后綴名指使用 Markdown 语法的结构化纯文本
|   |  |    +- 以减号间隔开始的有意义的E文 文章名,将成为访问时的URL 一部分
|   |  +- 日期
|   +- 月份
+- 年份

以及文本的前几行使用固定格式来声明一些文章信息:

1
2
3
4
5
6
7
8
9
---
layout: post
title: 如何在M$系统中管理 Gitcafe 的Pages 内容发布?
description: ~ 基于 msysgit,在M$ 系统中使用Git 来管理 Gitcafe 的Pages 发布Blog! 
categories: Howto
tags:  git gitcafe pages
---

...正文

具体说明:

  1. --- 约定控制标识符
  2. layout: 指出使用哪个模板,不要修改!除非你知道怎么回事儿!
  3. title: 文章标题
  4. description: 简述,有的模板首页只有简述没有正文的,输出的就是这儿的文字
  5. categories: 分类标签,使用空格区分多个
  6. tags: 内容标签,使用空格区分多个
  7. --- 约定控制标识符
  8. 最好有个空行同正文分开

注意!!! ~ 所有的配置声明格式为: 变量:+空格+配置内容 ,少了空格会引发各种问题的!

以上就是写文章所要知道的一切了,以下所有配置什么的, 99% 都是为了在 M$ 中使用 git 而已…

  • 真实的 html 页面是在服务端生成到 _site 目录中的
  • 大家在本地,反而不必要一定先生成 html 页面的
  • 甚至于,一般使用 .gitignore 配置文件,强制 git 忽略 _site 目录的变化,不进行版本监控!

###安装 msysgit 整备环境

  • 下载: msysGit-netinstall-1.8.0-preview20121022.exe
  • 参考:
  • 注意: ...选择Git文件夹,右键,选择Git Bash Here,会弹出shell命令行界面 可能不一定有
  • 不过,可以自然的进入 msysgit 安装目录中, 点击 git-cmd.bat
    • 在其中调用 bin 下的 bash.exe 进入方便的 shell 环境
    • 就可以自动的引用到 ssh-kengen.exe 生成对应的 SSH 密匙对!

0-bash.png

命令形如:

bash-3.1$ ssh-keygen -C "[email protected]" 
Your identification has been saved in /c/Documents and Settings/Administrator/.s
sh/id_rsa.
Your public key has been saved in /c/Documents and Settings/Administrator/.ssh/i
d_rsa.pub.
The key fingerprint is:
cf:1b:90:1b:25:0a:12:61:ff:ad:71:d0:ec:cd:5f:55 [email protected]
  • 输出的提示中清晰的指出了生成的密匙对文件在哪个目录
  • 只是形式同平时 cmd 环境中的有点不同,少了恶心的 : 以及分隔线是 UNIX 形式的
  • 所以, /c/Documents and Settings/Administrator/.ssh
  • 就是 C:\Documents and Settings\Administrator\.ssh
  • 从对应的文件中复制出公匙字串,这里是 id_rsa.pub 发布为个人帐号的公匙:

00-cafe-pubkey

再由仓库管理员加 gitcafe 帐号为 blogging 仓库的协作人员:

04-cafe-team

并在本地配置合理的全局变量:

bash-3.1$ git config --global user.name "zhouqi"
bash-3.1$ git config --global user.email "[email protected]"

可以使用git 命令观察是否生效:

bash-3.1$ git config --list
# ...
http.sslcainfo=/mingw/bin/curl-ca-bundle.crt
sendemail.smtpserver=/mingw/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.name=zhouqi
user.email=[email protected]

###使用 git 命令初始化本地工作仓库

从仓库首页可以获得有写入权限的 URI:

00-gituri.png

在合适的空白目录中 clone 远程仓库到本地,并同时切换为指定的 gitcafe-pages 分支:

bash-3.1$ pwd
/c/msysgit 

bash-3.1$ git clone  --branch gitcafe-pages [email protected]:Liebao/Liebao.git blog
Cloning into 'blog'...
The authenticity of host 'gitcafe.com (50.116.2.223)' can't be established.
RSA key fingerprint is 84:9e:c9:8e:7f:36:28:08:7e:13:bf:43:12:74:11:4e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitcafe.com,50.116.2.223' (RSA) to the list of known
 hosts.
remote: Counting objects: 127, done.
remote: Compressing objects: 100% (122/122), done.
remote: Total 127 (delta 47), reused 0 (delta 0)
Receiving objects: 100% (127/127), 458.50 KiB | 377 KiB/s, done.
Resolving deltas: 100% (47/47), done.

在资源管理器中就可以见到整个基于 jekyll 的团队blog 工程了!

2-cloned.png

####推荐配置

在 git 配置文件中声明有意义的别名:

修订 仓库目录中 .git/cofig 文件

  • 即,如果 clone 的仓库目录是 C:\msysgit\blog
  • 则,仓库配置文件就在 C:\msysgit\blog\.git

默认内容类似:

[remote "origin"]
    url = git://gitcafe.com/Liebao/Liebao.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = cafe
    merge = refs/heads/master

追加一节:

[remote "cafe"]
    url = [email protected]:Liebao/Liebao.git
    fetch = +refs/heads/*:refs/remotes/origin/*
  • 以后就可以使用 cafe 来替代 origin 来指代当前仓库名了!

1-config.png

###使用 markdownpad 进行文章编辑

  • 免费好编辑器! http://www.markdownpad.com/
  • 下载,安装,没什么好说的
  • 完全吻合 word 式编辑的环境! 左窗写 markdown,右窗自动编译成最终效果:

3-markdownpad.png

编辑保存后,使用 status 可以观察到变化:

bash-3.1$ git status
# On branch gitcafe-pages
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   _posts/2012-12-10-git-note.md
#
no changes added to commit (use "git add" and/or "git commit -a")

使用 add 收录变更,才能 commit, 最后 push 后,才能发布到 gitcafe 的团队仓库:

bash-3.1$ git add . 

bash-3.1$ git commit -m "zhouqi throught XP + msysgit"
[gitcafe-pages 6f50b04] zhouqi throught XP + msysgit
 1 file changed, 4 insertions(+)
 
bash-3.1$ git push cafe
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Counting objects: 7, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 426 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
To [email protected]:Liebao/Liebao.git
   89db4d6..6f50b04  gitcafe-pages -> gitcafe-pages
  • 注意! git 的提示非常智能,会好心提醒我们忘记的参数,不过,一般都是可以智能猜中我们的期待,完成合理的操作!
  • 基于以上的操作,在远程仓库中就可以见到自个儿的提交了!

11-cafe-same

####技巧: 图形化版本树!

bash-3.1$ git log --graph --pretty=oneline --abbrev-commit
* 59a267c 快速使用 README 教程M$+SourceTree 使用
*   3fa9827 Merge branch 'gitcafe-pages' of gitcafe.com:Liebao/Liebao into gitcafe-pages
|\  
| * 6f50b04 zhouqi throught XP + mysysgit
| * 89db4d6 使用协作人員的身份对仓库进行 add+ci
* | 2d7c376 before merge ci 先
|/  
* f20f7ef 根据协同过程,增补使用说明+++格式追加分层
* 7e9496e 根据协同过程,增补使用说明++
* 5f1e4bf 根据协同过程,增补使用说明
* 80846ab 演示多人协同时的流程+
*   e8b5e0f Merge branch 'gitcafe-pages' of gitcafe.com:Liebao/Liebao into gitcafe-pages
|\  
| * 9783bab 尝试另外成员本地的协同过程
* | ce33b2e 增补res 目录,准备发布可能的幻灯资料..
|/  
* 61f39ee 增补本地图片使用样例
...

121219-git-ll

小结

总之使用 git+gitcafe pagesM$ 中的日常操作命令只有:

  1. git clone --branch gitcafe-pages ...
  2. git add .
  3. git commit -a -m "注释"
  4. git push cafe gitcafe-pages
  5. git pull cafe gitcafe-pages

而基础协同流程就两种:

  • 第一次建立本地工作环境: 1->2->3->4
  • 以后平时: 5->2->3->4 的循环

参考

巡阅

2012-12-19  

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: #ZHGDG#


以上...


加入 珠海GDG

  1. 注册 Meetup
  2. 关注 Zhuhai GDG
  3. 或扫描: 2meetup

通过 珠海GDG 可以:

    第一时间获知谷歌最新技术,
    可以学到如何去谷歌平台上赚钱的思路和方法,
    可以认识很多有可能将来一起走上自己创业道路的人,
    可以学会把你的创新带向国际市场,
    参加那里的活动有经常和国际上的开发者们进行交流的机会...

PS:

若无意外,题图都是从原文提取或是通过 Google 图片搜索出来的, 版权属左, 不负责任 ;-)

PPS:

珠海GDG 微信/Blog 欢迎投稿,只要追自认内容吻合以下条件:

0. 有趣 ~ 至少是自个儿有兴趣的领域吧...
1. 有料 ~ 至少有点儿原创的东西吧..
2. 有种 ~ 至少不能是成功学吧!

有好物请及时通过邮件列表投稿成也: [email protected]
(发空邮件到 [email protected] 即完成订阅)

微信公号

栏目设定:

    G术图书 (gb:推荐好书,书无中外)
    D码点评 (dd:麻辣评点,善意满盈)
    G说公论 (gt:时评杂文,新旧不拘)
    珠的自白(dm:大妈自述,每周一篇)
    海选文章(hd:得要相信,大妈法眼)

总之, 请大家告诉大家, 珠海生活中的技术社区 都来订阅呗 ;-)

订阅方法

hacker emblem

GDG珠海 社区资源:

大妈的多重宇宙 - YouTube

全新自媒体系列...科学幻想,读书,说故事...
点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

订阅 substack 体验古早写作:
Zoom.Quiet’s Chaos42 | Substack


关注公众号, 持续获得相关各种嗯哼:
zoomquiet


蟒营®编程思维提高班Python版

**2021.01.11** 因大妈再次创业暂停定期开设, 转换为预约触发: