The opening

Nowadays, Git is very popular and has the tendency to dominate the world. If the Git and Github ICONS in your skill tree aren’t lit up yet, you’re embarrassed to call yourself a programmer. Not to mention Internet companies, many traditional companies I have contacted are migrating to Git from SVN, Clear Case, etc. Even big companies have a team to customize their own Git servers.

A lot of people will say “master Git and Github” on their resume, but if you ask them how well they know it, they will usually say “just add, commit, and push”.

But there are some more complicated scenarios that we encounter at work:

* Ignore some files * create, delete branches * Find the last person to change a line of code * Commit after you find a file that shouldn't have been committed * Commit after you find some files missing * Multiple changes in a file. How to commit only part of a file? * How can I tidy up the commit record? * Quickly locate which commit introduced the bug *...Copy the code

As front-line programmers, how can we learn Git quickly to get the most out of it?

Today, I’m going to introduce you to a tool called githug, which takes some of the scenes you might encounter and instantiates them into 55 levels:

#1: init
#2: config
#3: add
#4: commit
#5: clone
#6: clone_to_folder
#7: ignore
#8: include
#9: status
#10: number_of_files_committed
#11: rm
#12: rm_cached
#13: stash
#14: rename
#15: restructure
#16: log
#17: tag
#18: push_tags
#19: commit_amend
#20: commit_in_future
#21: reset
#22: reset_soft
#23: checkout_file
#24: remote
#25: remote_url
#26: pull
#27: remote_add
#28: push
#29: diff
#30: blame
#31: branch
#32: checkout
#33: checkout_tag
#34: checkout_tag_over_branch
#35: branch_at
#36: delete_branch
#37: push_branch
#38: merge
#39: fetch
#40: rebase
#41: repack
#42: cherry-pick
#43: grep
#44: rename_commit
#45: squash
#46: merge_squash
#47: reorder
#48: bisect
#49: stage_lines
#50: find_old_branch
#51: revert
#52: restore
#53: conflict
#54: submodule
#55: contributeCopy the code

The installation

Githug is written in Ruby and can be installed by using the following command: gem install githug

If you encounter permission problems, add sudo: sudo gem install githug

After the installation is complete, go to your usual directory in Terminal and typegithugThe game directory does not exist. Do you want to create oneyThen enter:



According to the promptcd git_hugEnter the game directory, ready to start the game.

Basic commands

Before we get started, we need to know some basic things about the game:

  • Play – Default command, check whether pass

  • Hint – Displays a level hint

  • Reset – Restarts a level or a specified level

  • Levels – Displays a list of levels

Let’s try it out,githug reset:

The sample

Let me use level 1 as an example to demonstrate the gameplay.

The name of the first level is:init“A new directory git_hug has been created, please initialize it as an empty repository.

Suppose NOW I don’t know how to pass, I can check the prompt:



The instructions were: “You may typegitCommand to viewgitCommand list.



Look at the last line. It used to begit initYou can initialize an empty warehouse and typegithugClearance testing:

That’s great! Smooth entry to the second level!

How’s that? Is that clear? The next 54 levels are up to you!

Helpful hints

Git help Subcommand, githug Hint, git help Subcommand, githug Hint, git help Subcommand Introduction to Git by Liao Xuefeng

In order to ensure that everyone can go through the customs smoothly and learn all the knowledge points, I will write the clearance strategy and introduce the gameplay of each level in detail. And I will not directly give the answer, but to demonstrate the whole process.

Good luck! I’ll see you tomorrow.