Convert Figma logo to code with AI

Gazler logogithug

Git your game on!

6,836
1,027
6,836
46

Top Related Projects

:computer: :mortar_board: Git-it is a (Mac, Win, Linux) Desktop App for Learning Git and GitHub

An interactive git visualization and tutorial. Aspiring students of git can use this app to educate and challenge themselves towards mastery of git!

5,801

Pro Git 2nd Edition

PDF on Git Internals

A list of cool features of Git and GitHub.

terminal game to test git skills

Quick Overview

Githug is an interactive game designed to teach Git commands and concepts. It provides a series of levels, each presenting a Git-related challenge that users must solve using Git commands. The project aims to make learning Git more engaging and hands-on.

Pros

  • Interactive and gamified approach to learning Git
  • Covers a wide range of Git concepts and commands
  • Provides immediate feedback on user actions
  • Can be used as a self-paced learning tool

Cons

  • May not cover the most advanced Git topics
  • Some levels might be too challenging for absolute beginners
  • Requires a local installation, which might be a barrier for some users
  • Updates and maintenance may be infrequent

Getting Started

To get started with Githug, follow these steps:

  1. Install Ruby on your system if not already installed.
  2. Install Githug using RubyGems:
    gem install githug
    
  3. Start the game by running:
    githug
    
  4. Follow the instructions for each level and use Git commands to solve the challenges.
  5. Use githug hint if you need help with a level.
  6. Progress through the levels to improve your Git skills.

Competitor Comparisons

:computer: :mortar_board: Git-it is a (Mac, Win, Linux) Desktop App for Learning Git and GitHub

Pros of git-it-electron

  • User-friendly graphical interface, making it more accessible for beginners
  • Cross-platform compatibility (Windows, macOS, Linux) due to Electron framework
  • Includes a built-in terminal for hands-on practice

Cons of git-it-electron

  • Larger file size and resource usage due to Electron framework
  • Less comprehensive coverage of Git concepts compared to githug
  • May not be as suitable for advanced users or those preferring command-line interfaces

Code Comparison

git-it-electron (JavaScript):

const Git = require('nodegit')
const repo = await Git.Repository.open(repoPath)
const commit = await repo.getHeadCommit()
console.log('Latest commit:', commit.message())

githug (Ruby):

def initialize_repo
  FileUtils.rm_rf(@grit_repo)
  @grit_repo = Grit::Repo.init(@grit_repo)
  FileUtils.touch(File.join(@grit_repo.working_dir, "README"))
  @grit_repo.add("README")
end

Both repositories aim to teach Git concepts, but they take different approaches. git-it-electron focuses on a graphical, interactive experience, while githug provides a more traditional command-line learning environment. The code snippets demonstrate the different languages and approaches used in each project, with git-it-electron utilizing JavaScript and the nodegit library, while githug employs Ruby and the Grit library for Git operations.

An interactive git visualization and tutorial. Aspiring students of git can use this app to educate and challenge themselves towards mastery of git!

Pros of learnGitBranching

  • Interactive visual representation of Git branching
  • Web-based, no installation required
  • Supports multiple languages

Cons of learnGitBranching

  • Limited to branching and merging concepts
  • Less comprehensive coverage of Git commands

Code Comparison

learnGitBranching:

var level = new Level({
  name: "Introduction to Git Commits",
  goalTreeString: "{\"branches\":{\"master\":{\"target\":\"C3\",\"id\":\"master\"}},\"commits\":{\"C0\":{\"parents\":[],\"id\":\"C0\",\"rootCommit\":true},\"C1\":{\"parents\":[\"C0\"],\"id\":\"C1\"},\"C2\":{\"parents\":[\"C1\"],\"id\":\"C2\"},\"C3\":{\"parents\":[\"C2\"],\"id\":\"C3\"}},\"HEAD\":{\"target\":\"master\",\"id\":\"HEAD\"}}",
  solutionCommand: "git commit;git commit",
  startTree: "{\"branches\":{\"master\":{\"target\":\"C1\",\"id\":\"master\"}},\"commits\":{\"C0\":{\"parents\":[],\"id\":\"C0\",\"rootCommit\":true},\"C1\":{\"parents\":[\"C0\"],\"id\":\"C1\"}},\"HEAD\":{\"target\":\"master\",\"id\":\"HEAD\"}}"
});

githug:

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 status` in your shell to see which files are untracked"
end
5,801

Pro Git 2nd Edition

Pros of progit2

  • Comprehensive Git documentation covering advanced topics
  • Available in multiple languages and formats (PDF, EPUB, MOBI)
  • Regularly updated with contributions from the community

Cons of progit2

  • Steeper learning curve for beginners
  • Less interactive than hands-on learning approaches

Code comparison

progit2 (content example):

==== Git Aliases

[source,console]
----
$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status
----

githug (level example):

difficulty 1
description "You have a blank Git repository. Create a file called 'README' in the repository."

solution do
  File.exists?("README")
end

hint do
  puts "You can create a file using touch or echo."
end

Summary

progit2 is a comprehensive Git reference book, while githug is an interactive Git learning game. progit2 offers in-depth knowledge but may be overwhelming for beginners. githug provides hands-on practice through challenges but lacks advanced topic coverage. Choose based on your learning style and Git proficiency level.

PDF on Git Internals

Pros of git-internals-pdf

  • Provides in-depth, comprehensive information about Git internals
  • Offers a PDF format for easy offline reading and reference
  • Suitable for users who prefer detailed, text-based learning materials

Cons of git-internals-pdf

  • Less interactive compared to hands-on learning approaches
  • May be overwhelming for beginners or those seeking quick, practical Git skills
  • Limited to static content without regular updates or community contributions

Code comparison

Not applicable for this comparison, as git-internals-pdf is a documentation repository and does not contain code samples that can be directly compared to Githug's interactive challenges.

Additional notes

Githug focuses on interactive learning through practical challenges, while git-internals-pdf provides detailed documentation on Git's inner workings. Githug is more suitable for hands-on learners and those seeking to improve their Git skills through practice, while git-internals-pdf caters to users interested in understanding the technical details behind Git's functionality.

Both repositories serve different purposes and can be complementary for users looking to gain a well-rounded understanding of Git. Githug offers practical experience, while git-internals-pdf provides the theoretical foundation and in-depth knowledge of Git's internal mechanisms.

A list of cool features of Git and GitHub.

Pros of github-cheat-sheet

  • Comprehensive collection of GitHub tips, tricks, and features
  • Regularly updated with new GitHub functionalities
  • Easily accessible reference for both beginners and experienced users

Cons of github-cheat-sheet

  • Passive learning approach, lacking hands-on practice
  • May not cover in-depth Git concepts or advanced workflows
  • Can be overwhelming due to the large amount of information presented

Code Comparison

While a direct code comparison isn't applicable for these repositories, we can compare their content structure:

github-cheat-sheet:

## Table of Contents
- [GitHub](#github)
  - [Ignore Whitespace](#ignore-whitespace)
  - [Adjust Tab Space](#adjust-tab-space)
  - [Commit History by Author](#commit-history-by-author)

githug:

difficulty 1
description "You want to start tracking a new file in your project. Start tracking a file called 'README'."

setup do
  init_from_level
end

solution do
  return false unless File.exists?(".git")
  `git status README`.include? "new file:"
end

terminal game to test git skills

Pros of git-game

  • More immersive, game-like experience with a storyline
  • Focuses on practical Git scenarios and real-world workflows
  • Encourages exploration and problem-solving skills

Cons of git-game

  • Less structured learning path compared to githug
  • Fewer levels and challenges overall
  • May be more challenging for absolute beginners

Code Comparison

git-game:

git clone https://github.com/git-game/git-game.git
cd git-game
cat README.md

githug:

gem install githug
githug

Key Differences

  • Installation: git-game is cloned directly, while githug is installed as a Ruby gem
  • Progression: git-game uses Git commands to progress, githug has a built-in level system
  • Learning style: git-game is more exploratory, githug is more guided and structured
  • Difficulty curve: git-game may be steeper for beginners, githug offers a gentler learning curve
  • Content focus: git-game emphasizes practical scenarios, githug covers a wider range of Git concepts

Both repositories aim to teach Git through interactive exercises, but they differ in their approach and target audience. git-game is better suited for those who prefer a more hands-on, exploratory learning experience, while githug offers a more structured and comprehensive curriculum for mastering Git concepts.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Githug

Git Your Game On

Build Status Code Climate

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.rb in 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

  1. 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 reset
    

    From the current level forward, the default branch will be master.

  2. githug command doesn't work

    Githug 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.1
    

    If you use rbenv, execute the below commands

    $ rbenv install 2.7.1
    $ rbenv global 2.7.1