目前公司使用的是svn，Cornerstone客户端，还是破解版的（逃。。）除了基本的add、commit、解决一下config、打个tag，很少用到别的功能。而我私下比较喜欢使用git。忽然在V2发现了 githug 的通关游戏，一共55关，赶紧开撸。
- githug play 检查是否过关
- githug hind 当前关卡提示
- githug reset 重启当前关卡或者重启到指定名字的关卡
- githug levels 所有关卡列表
A new directory,
git_hug, has been created; initialize an empty repository in it.
Set up your git name and email, this is important so that your commits can be identified.
here is a file in your folder called README, you should add it to your staging area
The README file has been added to your staging area, now commit it.
Clone the repository at https://github.com/Gazler/cloneme.
Clone the repository at https://github.com/Gazler/cloneme to my_cloned_repo.
The text editor ‘vim’ creates files ending in .swp (swap files) for all files that are currently open.We don’t want them creeping into the repository.Make this repository ignore .swp files.
Notice a few files with the ‘.a’ extension.We want git to ignore all but the ‘lib.a’ file.
There are some files in this repository, one of the files is untracked, which file is it?
There are some files in this repository, how many of the files will be committed?
看看有哪些文件将要提交，依然查看状态，找到to be commited下面的文件
A file has been removed from the working tree, however the file was not removed from the repository. Find out what this file was and remove it.
A file has accidentally been added to your staging area, find out which file and remove it from the staging area.NOTE Do not remove the file from the file system, only from git.
You’ve made some changes and want to work on them later. You should save them, but don’t commit them.
We have a file called
oldfile.txt. We want to rename it to
newfile.txtand stage this change.
You added some files to your repository, but now realize that your project needs to be restructured. Make a new folder named
srcand using Git move all of the .html files into this folder.
You will be asked for the hash of most recent commit. You will need to investigate the logs of the repository for this.
We have a git repo and we want to tag the current commit with
There are tags in the repository that aren’t pushed into remote repository. Push them now.
READMEfile has been committed, but it looks like the file
forgotten_file.rbwas missing from the commit. Add the file and amend your previous commit to include it.
可以使用 git commit –amend 修改上一次的提交信息，前提是你还没有push。
Commit your changes with the future date (e.g. tomorrow).
There are two files to be committed. The goal was to add each file as a separate commit, however both were added by accident. Unstage the file
to_commit_second.rbusing the reset command (don’t commit anything).
You committed too soon. Now you want to undo the last commit, while keeping the index.
A file has been modified, but you don’t want to keep the modification. Checkout the
config.rbfile from the last commit.
This project has a remote repository.Identify it
The remote repositories have a url associated to them.Please enter the url of remote_location.
You need to pull changes from your origin repository.
Add a remote repository called origin with the url https://github.com/githug/githug
Your local master branch has diverged from the remote origin/master branch. Rebase your commit onto origin/master and push it to remote.
There have been modifications to the app.rb file since your last commit.Find out which line has changed.
Someone has put a password inside the file
config.rbfind out who it was.
You want to work on a piece of code that has the potential to break things, create the branch test_code.
Create and switch to a new branch called my_branch.You will need to create a branch like you did in the previous level.
You need to fix a bug in the version 1.2 of your app. Checkout the tag v1.2.
You need to fix a bug in the version 1.2 of your app. Checkout the tag v1.2 (Note: There is also a branch named v1.2).
You forgot to branch at the previous commit and made a commit on top of it. Create branch test_branch at the commit before the last.
You have created too many branches for your project. There is an old branch in your repo called ‘delete_me’, you should delete it.
You’ve made some changes to a local branch and want to share it, but aren’t yet ready to merge it with the ‘master’ branch.Push only ‘test_branch’ to the remote repository
We have a file in the branch ‘feature’; Let’s merge it to the master branch.
Looks like a new branch was pushed into our remote repository. Get the changes without merging them with the local repository.
We are using a git rebase workflow and the feature branch is ready to go into master. Let’s rebase the feature branch onto our master branch.
Optimise how your repository is packaged ensuring that redundant packs are removed.
这道题画个问号，用git repack失败，用git gc成功，但是结果是一样的判定不同。
Your new feature isn’t worth the time and you’re going to delete it. But it has one commit that fills in
READMEfile, and you want this commit to be on the master as well.
加入git版本库中存在两个分支,当我们想将其中的某个分支commitID应用到另一个中,我们可以使用git cherry-pick commitID。这里有个cherry-pick的介绍。
Your project’s deadline approaches, you should evaluate how many TODOs are left in your code
Correct the typo in the message of your first (non-root) commit.
You have committed several times but would like all those changes to be one commit.
Merge all commits from the long-feature-branch as a single commit.
You have committed several times but in the wrong order. Please reorder your commits.
A bug was introduced somewhere along the way.You know that running ruby prog.rb 5 should output 15.You can also run make test.What are the first 7 chars of the hash of the commit that introduced the bug.
有一次提交有bug，通过运行 ruby prog.rb 5 查看输出是否是15来找出这个bug提交。通过git bisect来一次次的试。
You’ve made changes within a single file that belong to two different features, but neither of the changes are yet staged. Stage only the changes belonging to the first feature.
注：交互式add（或者叫add块），将会一个块一个快的循环你的改动。使用命令git add -p时，你可以在每个改动“块”（即：连续的改动会被组织到一起）时进行一些选择，比如：切分当前块为更小的块、跳过一个改动块、甚至手动的编辑该块，你可以敲入?来查看所有该命令提供的选项。
You have been working on a branch but got distracted by a major issue and forgot the name of it. Switch back to that branch.
You have committed several times but want to undo the middle commit.
All commits have been pushed, so you can’t change existing history.
git revert 是撤销某次操作，此次操作之前的commit都会被保留
git reset 是撤销某次提交，但是此次之后的修改都会被退回到暂存区
You decided to delete your latest commit by running
git reset --hard HEAD^. (Not a smart thing to do.) You then change your mind, and want that commit back. Restore the deleted commit.
You need to merge mybranch into the current branch (master). But there may be some incorrect changes in mybranch which may cause conflicts. Solve any merge-conflicts you come across and finish the merge.
You want to include the files from the following repo:
https://github.com/jackmaney/githug-include-meinto a the folder
./githug-include-me. Do this without cloning the repo or copying the files from the repo into this repo.
注：git Submodule 是一个很好的项目协作工具，他允许类库项目做为repository,子项目做为一个单独的git项目存在父项目中，子项目可以有自己的独立的commit，push，pull。而父项目以Submodule的形式包含子项目，父项目可以指定子项目header，父项目中会提交 Submodule的信息，在clone父项目的时候可以把Submodule初始化。
This is the final level, the goal is to contribute to this repository by making a pull request on Github. Please note that this level is designed to encourage you to add a valid contribution to Githug, not testing your ability to create a pull request. Contributions that are likely to be accepted are levels, bug fixes and improved documentation.