不支持 Ruby 3.0.0 及以上版本,建议用 2.7.1;默认分支不是 master 会导致答案校验失败,需先执行 git config --global init.defaultBranch master 再 githug reset;首次运行会在当前目录创建 githug 目录存放关卡资源
gem install githug
githugREADME 未说明,仅要求 Ruby 1.8.7 或更高版本,无 GPU 或显存要求
用闯关方式练 Git 命令的交互式学习工具,每关都要你敲对命令才能过关
把 Git 命令学习做成闯关游戏,通过一系列任务让你在实战中掌握分支、合并、变基等操作,适合新手边玩边练。
核心能力
- 按关卡设计,每关用 git 命令解出正确答案
- 提供 play、hint、reset、levels 四个游戏命令
- 内置关卡提示,卡住时可查看线索
- 用 Ruby DSL 编写自定义关卡并测试
- 支持 Linux、OS X 和 Windows 平台
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Githug
Git Your Game On
About
Githug is designed to give you a practical way of learning git. It has a series of levels, each requiring you to use git commands to arrive at a correct answer.
Playing Githug
Githug should work on Linux, OS X and Windows.
Prerequisites
Githug requires Ruby 1.8.7 or higher.
You can check which version of Ruby is installed with the following command:
ruby --version
If ruby is not installed, follow the installation instructions on ruby-lang.org.
Installation
To install Githug, run
gem install githug
If you get a complaint about permissions, you can rerun the command with sudo:
sudo gem install githug
Usage with Docker
An unofficial Docker image for this project by @odiraneyya is available on (Docker Hub).
Starting the Game
After the gem is installed change directory to the location where you want the game-related assets to be stored.
Then run githug:
githug
You will be prompted to create a directory.
No githug directory found, do you wish to create one? [yn]
Type y (yes) to continue, n (no) to cancel and quit Githug.
Commands
Githug has 4 game commands:
- play - The default command, checks your solution for the current level
- hint - Gives you a hint (if available) for the current level
- reset - Reset the current level or reset the level to a given name or path
- levels - List all the levels
Change Log
The change log is available on the wiki. Change log
Contributing
To suggest a level or create a level that has been suggested, check out the wiki.
Get yourself on the contributors list by doing the following:
- Fork the repository
- Make a level in the levels directory (covered below)
- Add your level to the LEVELS array inside
lib/githug/level.rbin a position that makes sense (the "commit" level after the "add" and "init" levels for example) - Make sure your level works (covered below)
- Submit a pull request
Todo List
- A follow-up to the level, more information on a specific command, etc.
- More levels!
Writing Levels
Githug has a DSL for writing levels. Here is an example:
difficulty 1
description "There is a file in your folder called README, you should add it to your staging area"
setup do
repo.init
FileUtils.touch("README")
end
solution do
return false unless repo.status.files.keys.include?("README")
return false if repo.status.files["README"].untracked
true
end
hint do
puts "You can type `git` in your shell to get a list of available git commands"
end
difficulty, description and solution are required.
You can include multiple hints like this:
hints [
"You can type `git` in your shell to get a list of available git commands",
"Check the man for `git add`"]
By default, setup will remove all files from the game folder. You do not need to include a setup method if you don't want an initial git repository (if you are testing git init or only checking an answer.)
You can call repo.init to initialize an empty repository.
All methods called on repo are sent to the grit gem if the method does not exist, and you can use that for most git related commands (repo.add, repo.commit, etc.).
Another method exists called init_from_level and it is used like so:
setup do
init_from_level
end
This will copy the contents of a repository specified in the levels folder for your level. For example, if your level is called "merge" then it will copy the contents of the "merge" folder. It is recommended that you perform the following steps:
- mkdir "yourlevel"
- cd "yourlevel"
- git init
- some git stuff
- important rename ".git" to ".githug" so that it isn't treated as a submodule
- cd "../"
- git add "yourlevel"
After doing this, your level should be able to copy the contents from that git repository and use those for your level. See the "blame" level for an example of this.
Testing Levels
The easiest way to test a level is:
- Change into your git_hug repository
- Run
githug reset PATH_TO_YOUR_LEVEL - Solve the level
- Run
githug test PATH_TO_YOUR_LEVEL
Please note that the githug test command can be run as githug test --errors to get an error stack trace from your solve method.
It would be ideal if you add an integration test for your level. These tests live in spec/githug_spec and must be run in order. If you add a level but do not add a test, please add a simple skip_level test case similar to the contribute level.
FAQs
-
Answers are not being checked properly
This is a common issue we are facing and we are actively working to fix it.
For now, run the following commands to change the default branch name to master. This should fix most of the issues you may face.
$ git config --global init.defaultBranch master $ githug resetFrom the current level forward, the default branch will be
master. -
githugcommand doesn't workGithug currently isn't supported on ruby versions ^3.0.0. Use any ruby version below 3.0.0 (preferrably 2.7.1).
If you use rvm, execute the below commands
$ rvm install 2.7.1 $ rvm use 2.7.1If you use rbenv, execute the below commands
$ rbenv install 2.7.1 $ rbenv global 2.7.1