githug游戏练习git命令

环境:mac电脑下

这货叫做githug,而不是大家熟悉的github,其主要目的是通过游戏的形式来让我们练习git的使用。

安装githug
githug是ruby写的一个应用。所以先要安装ruby,然后输入

gem install githug

安装了githug命令后,在自己觉得合适练习的目录下创建一个空目录,用于练习git命令。
例如我是在自己是一个学习目录study_folder下创建:mkdir git_hug,创建了git_hug这个空文件夹。
命令指定到git_hug这个空文件下,键入命令:

githug

于是开始你的githug之旅。

********************************************************************************
*                                    Githug                                    *
********************************************************************************
Welcome to Githug!

若出现:

********************************************************************************
*                                    Githug                                    *
********************************************************************************
No githug directory found, do you wish to create one? [yn]  y

强烈建议把git的编辑器转换为vim

git config --global core.editor "/usr/local/bin/vim"

以下是我自己的githug之旅:完成当前答题后,键入 githug 命令,会进入到下一题。
第一关:

Name: init
Level: 1
Difficulty: *

A new directory, `git_hug`, has been created; initialize an empty repository in it.

意思:初始化一个仓库。
答案:

git init

提示:完成后,键入githug进入下一关。

第二关:

Name: config
Level: 2
Difficulty: *

Set up your git name and email, this is important so that your commits can be identified.

意思:初始化仓库后,设置你的名字和email。
答案:

git config --global user.name "xuqingsong"
git config --global user.email "qingsong.xu.developer@gmail.com"

键入:githug命令进入下一关。

第三关:

********************************************************************************
*                                    Githug                                    *
********************************************************************************
What is your name? xuqingsong
What is your email? qingsong.xu.developer@gmail.com
Your config has the following name: xuqingsong
Your config has the following email: qingsong.xu.developer@gmail.com
Congratulations, you have solved the level!

Name: add
Level: 3
Difficulty: *

There is a file in your folder called `README`, you should add it to your staging area
Note: You start each level with a new repo. Don't look for files from the previous one.

第三关会要求你输入第二关set的user.name及user.email。输入正确后进入第三关。
第三关的意思是:这里有个“README”的文件,你应该add它到你的暂存区域。
答案:

git add README

第四关:

文章目录