"githug"git Game Clearance Process

Source: Internet
Author: User
Tags glob tag name

Githug

What is this, he meow? Isn't GitHub misspelled, and what's the relationship with Git? What's the relationship with the game?

In fact, his body is here: https://github.com/Gazler/githug, this command-line tool is designed to practice your Git skills, which instantiate some of the scenarios that you might encounter, become a level, a total of 55 levels, So the description of his image as a Git game.

Since is the game, as a professional gamer, customs clearance is my ultimate goal!!!

Install the game

Nothing to say, the terminal run the following command, if you hit the wall, move the ladder by themselves


Install the game (steal a picture) game start

githugYou can start the game with direct input! At the beginning, you will be asked whether to create a folder, enter a y confirmation to create, and the subsequent actions will be in this folder.


The game starts with the first pass (Init)

Immediately, immediately into the first level, follow the prompts to initialize this githug folder for the warehouse. Completing the level can be done by invoking githug play the verification action, and the success will go to the next level


First off the second pass (Config)

To set the Git username and mailbox, I set the warehouse level to not affect the global configuration.


Second off third level (ADD)

Use the add command to add a README file to the staging area.


Third off fourth (Commit)

Submit a README file, remember that every time you commit use -m parameters Plus notes is a good habit


Paste_image.png Fifth (Clone)

Clone a repository, the default folder name is the remote repository name


Sixth off (Clone to folder)

Also cloning a warehouse, the difference is that you can specify a folder name


Seventh off (Ignore)

.swpfiles with all suffix names are ignored. This is opened with the Vim editor .gitignore , which records git's rules for ignoring files, and no vim can be used by its classmates.


Seventh Pass

Use Regular (Glob mode) to match all .swp files and then save and exit


Operation. gitignore file Eighth (Include)

Except for lib.a files, all other .a suffix names are ignored. As with the previous action, modify the .gitignore file


Eighth Pass

Where # the beginning of the comment, with *.a matching all .a files, the ! beginning represents do not ignore


Operation. gitignore file Nineth (Status)

View all untracked files that are in status. Using git status View the status of the current warehouse, you can see that the red part is untracked the state of the file


Nineth off Tenth Pass (number of files committed)

is actually looking at the file in the staged state, the yellow part of the figure is, so the number is 2


Tenth off 11th Pass (RM)

A file was deleted from the hard drive, but it was not removed from the Git repository, found and removed from the Git repository. Delete is also a modification of one, submit this change just fine


11th off 12th Pass (RM cached)

Say a new file is staging area removed from the. As required, you should not delete this file directly from your hard drive, just remove it from Git. Plus --cache can be a file just removed from the staging area, will not really delete the physical file, if you want to even delete this physical file, please use the -f option


12th off 13th Pass (stash)

Temporarily submit a file. This operation is very useful when you need to save changes temporarily, but do not want to submit! And Git maintains a stack to save, so it supports submission multiple times. If you need to recover a commit, git stash apply you can use it.


13th off 14th Pass (Rename)

Renames the file. First, this file needs to be already in the tracking state before you can use the git mv command, automatically in the staging state after the operation is completed.


Renaming a file 15th off (restructure)

Move all .html files to the src folder. git mvThe second parameter can accept the file or directory, and if it is a directory, the file is placed directly inside the directory, and you can use regular (Glob mode) to match all. html files


15th off 16th Pass (LOG)

Find the hash value of the latest commit. Use git log view history to submit records, find the latest commit hash value, record the user answer questions


Answer the question

This is in reverse chronological order, the latest in the front, commit followed by the keyword is the commit hash value


View History 17th Pass (TAG)

Tag for the latest commit. No extra parameter is the tag for the current commit, and of course it can be used for a specific commit


Paste_image.png 18th Pass (Push tags)

Pushes all local tags to the remote. --tagsparameter indicates that all tags are pushed to the remote


18th off 19th Pass (Commit amend)

A file was omitted from the last submission, and the file was made up in that submission. In fact, the use git commit --amend will go into the editing interface to modify the note information, I here directly :wq save and exit


19th off 20th Pass (Commit in feature)

Specify a future time for the submission.


20th Pass
Note Operator Interface 21st (Reset)

Two files have been added staging area , but only one of them is to be submitted. Use git reset a version that can be overwritten with a version in the warehouse staging area .

    • git resetstaging areaIf the working directory file has no other modifications, the modifications in the warehouse are staging area applied to the working directory . Conversely working directory , the version in will be retained and discarded staging area in the modification.
    • git checkoutis overwritten with the staging area version in working directory .

      Paste_image.png
22nd off (Reset soft)

Undo the last commit.

    • --softParameter puts the last modification in thestaging area
    • --mixedParameter puts the last modification in theworking directory
    • --hardParameter discards the last modification directly

      22nd Pass
23rd off (Checkout file)

Discard a change of one time, using the last committed version. checkoutand reset The difference between the reference 21st


23rd off 24th off (Remote)

View the remote repository. In fact, can not add -v parameters, plus this parameter can only be the address also output (I did not think the next level is to examine this parameter, the usual habit of adding this parameter ...) )


24th off 25th Pass (remote URL)

View the URL of a remote repository


25th off 26th off (pull)

Pull the remote repository.
You can actually specify a branch, in the following format

local

The corresponding push format is as follows

push origin local : remote

The branch order of the two operations to be aware of is the opposite , the memory method is very simple, the pull is from the far end to the local, so the remote is in front, and the push is from the local to the far end, so local in front.


26th off 27th off (Remote add)

Add a remote repository


27th off 28th Pass (Push)

Push local modification to remote


Paste_image.png 29th Pass (Diff)

View staging area and the working directory differences in the files.


29th Pass

git diffthe corresponding display results


Difference Information 30th (Blame)

View the modified person for a file. This command is simply evil, the pot finally someone back!!!


30th Pass

git blameLists who is the modified person for each line in the file


File Modification record 31st off (Branch)

Create a branch


31st off 32nd Pass (Checkout)

Create a branch and switch the past. In fact, it git checkout -b my_branch is to create a branch and switch the past, and this method is more convenient, usually use more


Paste_image.png 33rd Pass (Checkout tag)

Switch to a specific tag


33rd off 34th Pass (Checkout tag over branch)

Switch to a specific branch, but the branch name and tag name overlap


34th off 35th Pass (branch at)

Create a new branch based on a specific commit


35th off 36th off (delete branch)

Delete a branch


36th off 37th Pass (Push Branch)

Push a branch to the remote repository


Paste_image.png 38th (merge)

Merge branches. In order to simplify the branching model, you can use rebase instead, and subsequent levels will be encountered.


38th off 39th Pass (FETCH)

Gets the remote modification, but does not merge to the current branch. In fact, it git pull is git fetch and git merge composition.


39th off 40th Pass (rebase)

Actually don't know how to translate git rebase this command. The idea is to differentiate two branches from a commit, and then one branch needs to merge the changes from another branch, but instead of leaving the two-branch merge traces on the commit record, leave only one branch to record the changes on both sides in a sequential order.

git rebaseAll modifications of a branch are applied again on another branch, so on the commit record, all commits of one branch are found before or after the other branch. Then delete another merged branch, keeping the branch concise.

git rebase master featureIndicates that the modification on the top is feature master applied again


40th Pass

Corresponding to the first one git log --graph -all , the --graph submission record is displayed graphically, and --all the commit record for all branches is displayed.


Original state

corresponding to the first and two git log --graph -all , you can find that only one branch is retained, which looks a lot more concise.


Paste_image.png

When using this command, it is important to note that you do not rebase which updates have been pushed to the public library, because this is a re-application of the changes, so the updates to the public library may have been synchronized by other collaborators, and if these modifications are rebase again, it will likely be en

41st Pass (RePack)

Packaging loose objects that are not packaged in a repository


41st off 42nd Pass (Cherry pick)

Apply a commit modification.


42nd Pass

Find the commit we want, and record its hash value.
ca32a6dac7b6f97975edbe19a4296c2ee7682f68


Paste_image.png 43rd off (Grep)

git grepSupport a variety of conditional search and regular expression, usually not much, but feel powerful.


43rd Pass

git grep TODOthe corresponding result


Search Results 44th Pass (rename commit)

Rename the commit. When it comes to committing changes, you should think of the git rebase -i command, which accepts a parameter (the hash value of the commit), which lists all commits after this commit, and then can do the corresponding action for each commit.


44th Pass

The commit record before renaming


Before renaming

Change the pre-submission that needs to be renamed to pickreword


Select the submission you want to rename

Edit into new notes, save and launch


Paste_image.png 45th off (squash)

Merge multiple commits.


45th Pass

The commit record before the merge.


Paste_image.png

Changes to or before the submission of a merge will be required pick squash s . squashthe delegate is incorporated into the previous submission, saved and exited.


Paste_image.png

Modify comments for a new submission


Paste_image.png 46th (merge squash)

Applies all modifications on a branch to a single commit. The default modifications are entered staging area


Paste_image.png 47th off

Rearrange the submission order.


47th Pass

Before sorting, correspond to the firstgit log


Paste_image.png

In the editing interface, Second commit the Third commit order of the Exchange


Paste_image.png

After sorting, correspond to a secondgit log


Paste_image.png 48th off

Use to git log View all submission records, too long I'm not going to post it all, find the first commitf608824888b83bbedc1f658be7496ffea467a8fb


Paste_image.png

git bisect start master f608824888b83, it master is a node with bugs and f608824888b83 is a node without bugs.


Paste_image.png 49th (Stage lines)

In fact, the part of the file to modify this requirement is usually more common, but usually use the Source Tree to operate, but after seeing the problem, it seems to have opened a door.


Paste_image.png
Paste_image.png
Paste_image.png 50th (Find old branch)

git reflogYou can list all the action records, so it's not difficult to find the information you've forgotten.


50th Pass

git reflogthe corresponding display content


Paste_image.png 51st off (Revert)

The reset difference is that revert only revokes the current commit, and subsequent changes to the commit action are retained, but reset all subsequent modifications of the commit operation are returned to the staging area or discarded.


51st Pass

This is the record before the undo operation is performed, corresponding to the firstgit log


Pre-Revocation Records

The undo operation will generate a new commit, save and exit.


A new commit

After the revocation of the record, it does not destroy the original record, corresponding to a secondgit log


Record of revocation 52nd (Restore)

Based on previous experience, git reflog you can view all the operational records, so you can recover the site as long as you find the commit ID before the error.


52nd Pass

After the execution of the git reflog screen, according to the operation record, find your wrong operation before the commit ID


Operation Record 53rd off (Conflict)

Conflict handling is often common in collaborative work, but it is important to note that conflicting files are in working directory and need to be added to staging area and submitted after the conflict has been resolved.


53rd Pass

In fact, the completion of the conflict resolution of the picture lost, can only dictate.
<<<<<<< HEADThe ======= content between the branches to represent the changes, master ======= to >>>>>> mybranch the content of the branch to represent mybranch the changes, to preserve the branch of the modification mybranch , delete master branch changes can be, of course, the lines of these special symbols are also deleted.


Dealing with conflict 54th (Submodule)

Submodule is a handy command to break a warehouse into multiple sub-modules, especially when the project is large and dependent on other Git projects, such as Cocos2d-x. Although easy to use, but the threshold is relatively high, if the maintenance of good submodule still need to be studied carefully.


54th off 55th Pass (Contribute)

In fact, it can be considered as customs clearance, if interested, can go to GitHub for this project to contribute code.


End of 55th Pass

In fact, all the levels here are just the tip of Git's iceberg, and Git's charm is far more than that, and we need to explore it slowly.

If the article has a wrong expression, please correct it.

Finally, thanks to this article take me into the pit:
Http://gold.xitu.io/entry/5684844560b2cd25b7cb41a3

"githug"git Game Clearance Process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.