➜ ruby githug ******************************************************************************** * Githug * ******************************************************************************** No githug directory found, do you wish to create one? [yn] y Welcome to Githug!
1 - 5
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Name: init Level: 1 Difficulty: *
A new directory, `git_hug`, has been created; initialize an empty repository in it.
➜ ruby git config --global core.editor "/usr/bin/vim" ➜ ruby cd git_hug ➜ git_hug git init Initialized empty Git repository in /Users/yangxiao/Documents/ruby/git_hug/.git/ ➜ git_hug git:(master) ls ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Name: config Level: 2 Difficulty: *
Set up your git name and email, this is important so that your commits can be identified.
➜ git_hug git:(master) git config user.name sagittariusyx ➜ git_hug git:(master) git config user.email "ssdut.xiao@gmail.com" ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** What is your name? sagittariusyx What is your email? ssdut.xiao@gmail.com Your config has the following name: sagittariusyx Your config has the following email: ssdut.xiao@gmail.com Congratulations, you have solved the level!
3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Name: add Level: 3 Difficulty: *
There is a file in your folder called `README`, you should add it to your staging area Note: You start each level with a new repo. Don't look for files from the previous one.
➜ git_hug git:(master) ✗ ls README ➜ git_hug git:(master) ✗ vim README ➜ git_hug git:(master) ✗ git add README ➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Name: commit Level: 4 Difficulty: *
The `README` file has been added to your staging area, now commit it.
Clone the repository at https://github.com/Gazler/cloneme.
➜ git_hug git clone https://github.com/Gazler/cloneme Cloning into 'cloneme'... remote: Counting objects: 7, done. remote: Total 7 (delta 0), reused 0 (delta 0), pack-reused 7 Unpacking objects: 100% (7/7), done. Checking connectivity... done. ➜ git_hug githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
6 - 10
6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Name: clone_to_folder Level: 6 Difficulty: *
Clone the repository at https://github.com/Gazler/cloneme to `my_cloned_repo`.
➜ git_hug git clone https://github.com/Gazler/cloneme my_cloned_repo Cloning into 'my_cloned_repo'... remote: Counting objects: 7, done. remote: Total 7 (delta 0), reused 0 (delta 0), pack-reused 7 Unpacking objects: 100% (7/7), done. Checking connectivity... done. ➜ git_hug githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Name: ignore Level: 7 Difficulty: **
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 those swap files which are ending in `.swp`.
➜ git_hug git:(master) ✗ vim .gitignore *.swp [exit VIM] ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Name: include Level: 8 Difficulty: **
Notice a few files with the '.a' extension. We want git to ignore all but the 'lib.a' file.
➜ git_hug git:(master) ✗ vim .gitignore *.a !lib.a [exit VIM] ➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
There are some files in this repository, one of the files is untracked, which file is it?
➜ git_hug git:(master) ✗ git status On branch master
Initial commit
Changes to be committed: (use "git rm --cached <file>..." to unstage)
new file: Guardfile new file: README new file: config.rb new file: deploy.rb new file: setup.rb
Untracked files: (use "git add <file>..." to include in what will be committed)
database.yml
➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** What is the full file name of the untracked file? database.yml Congratulations, you have solved the level!
There are some files in this repository, how many of the files will be committed?
➜ git_hug git:(master) ✗ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)
new file: rubyfile1.rb modified: rubyfile4.rb
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
modified: rubyfile5.rb
Untracked files: (use "git add <file>..." to include in what will be committed)
rubyfile6.rb rubyfile7.rb
➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** How many changes are going to be committed? 2 Congratulations, you have solved the level!
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.
➜ git_hug git:(master) ✗ git status On branch master Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
deleted: deleteme.rb
no changes added to commit (use "git add" and/or "git commit -a") ➜ git_hug git:(master) ✗ git rm deleteme.rb rm 'deleteme.rb' ➜ git_hug git:(master) ✗ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)
deleted: deleteme.rb
➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
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.
➜ git_hug git:(master) ✗ git status On branch master
Initial commit
Changes to be committed: (use "git rm --cached <file>..." to unstage)
new file: deleteme.rb
➜ git_hug git:(master) ✗ git rm --cached deleteme.rb rm 'deleteme.rb' ➜ git_hug git:(master) ✗ git status On branch master
Initial commit
Untracked files: (use "git add <file>..." to include in what will be committed)
deleteme.rb
nothing added to commit but untracked files present (use "git add" to track) ➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
You've made some changes and want to work on them later. You should save them, but don't commit them.
➜ git_hug git:(master) ✗ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
modified: lyrics.txt
no changes added to commit (use "git add" and/or "git commit -a") ➜ git_hug git:(master) ✗ git stash Saved working directory and index state WIP on master: 0206059 Add some lyrics HEAD is now at 0206059 Add some lyrics ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
We have a file called `oldfile.txt`. We want to rename it to `newfile.txt` and stage this change.
➜ git_hug git:(master) git mv oldfile.txt newfile.txt ➜ git_hug git:(master) ✗ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)
renamed: oldfile.txt -> newfile.txt
➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
You added some files to your repository, but now realize that your project needs to be restructured. Make a new folder named `src` and using Git move all of the .html files into this folder.
➜ git_hug git:(master) ls about.html contact.html index.html ➜ git_hug git:(master) mkdir src ➜ git_hug git:(master) git mv *.html src ➜ git_hug git:(master) ✗ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)
➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
16 - 20
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Name: log Level: 16 Difficulty: **
You will be asked for the hash of most recent commit. You will need to investigate the logs of the repository for this.
➜ git_hug git:(master) git log ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** What is the hash of the most recent commit? 053adb5 Congratulations, you have solved the level!
17
1 2 3 4 5 6 7 8 9 10 11 12 13
Name: tag Level: 17 Difficulty: **
We have a git repo and we want to tag the current commit with `new_tag`.
➜ git_hug git:(master) git tag new_tag ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Name: push_tags Level: 18 Difficulty: **
There are tags in the repository that aren't pushed into remote repository. Push them now.
From /var/folders/6v/0_m2zjlx1_vbvv4wgmlq0qm40000gn/T/d20170117-10523-xtjnrf/ * [new branch] master -> origin/master ➜ git_hug git:(master) git status On branch master nothing to commit, working directory clean ➜ git_hug git:(master) githug --tags git push ????? ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
The `README` file has been committed, but it looks like the file `forgotten_file.rb` was missing from the commit. Add the file and amend your previous commit to include it.
➜ git_hug git:(master) ✗ git status On branch master Untracked files: (use "git add <file>..." to include in what will be committed)
forgotten_file.rb
nothing added to commit but untracked files present (use "git add" to track) ➜ git_hug git:(master) ✗ git add forgotten_file.rb ➜ git_hug git:(master) ✗ git commit --amend
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.rb` using the reset command (don't commit anything).
➜ git_hug git:(master) ✗ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)
new file: to_commit_first.rb new file: to_commit_second.rb
➜ git_hug git:(master) ✗ git reset HEAD to_commit_second.rb ➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
You committed too soon. Now you want to undo the last commit, while keeping the index.
➜ git_hug git:(master) git reset --soft HEAD^1 ➜ git_hug git:(master) ✗ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)
new file: newfile.rb
➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
A file has been modified, but you don't want to keep the modification. Checkout the `config.rb` file from the last commit.
➜ git_hug git:(master) ✗ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
modified: config.rb
no changes added to commit (use "git add" and/or "git commit -a") ➜ git_hug git:(master) ✗ git checkout config.rb ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
24
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Name: remote Level: 24 Difficulty: **
This project has a remote repository. Identify it.
➜ git_hug git:(master) git remote my_remote_repo ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** What is the name of the remote repository? my_remote_repo Congratulations, you have solved the level!
25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Name: remote_url Level: 25 Difficulty: **
The remote repositories have a url associated to them. Please enter the url of remote_location.
➜ git_hug git:(master) git remote -v my_remote_repo https://github.com/Gazler/githug (fetch) my_remote_repo https://github.com/Gazler/githug (push) remote_location https://github.com/githug/not_a_repo (fetch) remote_location https://github.com/githug/not_a_repo (push) ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** What is the url of the remote repository? https://github.com/githug/not_a_repo Congratulations, you have solved the level!
26 - 30
26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Name: pull Level: 26 Difficulty: **
You need to pull changes from your origin repository.
Your local master branch has diverged from the remote origin/master branch. Rebase your commit onto origin/master and push it to remote.
➜ git_hug git:(master) git rebase origin/master First, rewinding head to replay your work on top of it... Applying: First commit Applying: Second commit Applying: Third commit ➜ git_hug git:(master) git push origin master Counting objects: 6, done. Delta compression using up to 4 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (6/6), 612 bytes | 0 bytes/s, done. Total 6 (delta 2), reused 0 (delta 0) To /var/folders/6v/0_m2zjlx1_vbvv4wgmlq0qm40000gn/T/d20170120-2068-u1sjza/.git f3aeb43..2e33184 master -> master ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
29
1 2 3 4 5 6 7 8 9 10 11 12 13
Name: diff Level: 29 Difficulty: **
There have been modifications to the `app.rb` file since your last commit. Find out which line has changed.
➜ git_hug git:(master) ✗ git diff app.rb ➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** What is the number of the line which has changed? 26 Congratulations, you have solved the level!
30
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Name: blame Level: 30 Difficulty: **
Someone has put a password inside the file `config.rb` find out who it was.
➜ git_hug git:(master) ✗ git blame config.rb ➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Who made the commit with the password? Spider Man Congratulations, you have solved the level!
31 - 35
31
1 2 3 4 5 6 7 8 9 10 11 12
Name: branch Level: 31 Difficulty: *
You want to work on a piece of code that has the potential to break things, create the branch test_code.
➜ git_hug git:(master) git branch test_code ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
32
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Name: checkout Level: 32 Difficulty: **
Create and switch to a new branch called my_branch. You will need to create a branch like you did in the previous level.
➜ git_hug git:(master) git checkout -b my_branch Switched to a new branch 'my_branch' ➜ git_hug git:(my_branch) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
You need to fix a bug in the version 1.2 of your app. Checkout the tag `v1.2`.
➜ git_hug git:(master) git checkout v1.2 Note: checking out 'v1.2'.
You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at f83bf75... Some more changes ➜ git_hug git:(f83bf75) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
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`).
➜ git_hug git:(master) git checkout tags/v1.2 Note: checking out 'tags/v1.2'.
You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 2aede5e... Some more changes ➜ git_hug git:(2aede5e) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
35
1 2 3 4 5 6 7 8 9 10 11 12 13
Name: branch_at Level: 35 Difficulty: ***
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.
➜ git_hug git:(master) git branch test_branch HEAD^1 ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
36 - 40
36
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Name: delete_branch Level: 36 Difficulty: **
You have created too many branches for your project. There is an old branch in your repo called 'delete_me', you should delete it.
➜ git_hug git:(master) git branch -d delete_me Deleted branch delete_me (was b60afe2). ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
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
➜ git_hug git:(master) git push origin test_branch Counting objects: 6, done. Delta compression using up to 4 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (6/6), 585 bytes | 0 bytes/s, done. Total 6 (delta 3), reused 0 (delta 0) To /var/folders/6v/0_m2zjlx1_vbvv4wgmlq0qm40000gn/T/d20170120-2746-zswfij/.git * [new branch] test_branch -> test_branch ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Name: merge Level: 38 Difficulty: **
We have a file in the branch 'feature'; Let's merge it to the master branch.
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.
➜ git_hug git:(master) git checkout feature Switched to branch 'feature' ➜ git_hug git:(feature) git rebase master First, rewinding head to replay your work on top of it... Applying: add feature ➜ git_hug git:(feature) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
41 - 45
41
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Name: rebase_onto Level: 41 Difficulty: **
You have created your branch from `wrong_branch` and already made some commits, and you realise that you needed to create your branch from `master`. Rebase your commits onto `master` branch so that you don't have `wrong_branch` commits.
➜ git_hug git:(readme-update) git rebase --onto master wrong_branch First, rewinding head to replay your work on top of it... Applying: Add app name in readme Applying: Add `About` header in readme Applying: Add `Install` header in readme ➜ git_hug git:(readme-update) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
42
git gc 需要深研究搞明白,稍后我会整理。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Name: repack Level: 42 Difficulty: **
Optimise how your repository is packaged ensuring that redundant packs are removed.
➜ git_hug git:(master) git gc Counting objects: 3, done. Writing objects: 100% (3/3), done. Total 3 (delta 0), reused 0 (delta 0) ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
Your new feature isn't worth the time and you're going to delete it. But it has one commit that fills in `README` file, and you want this commit to be on the master as well.
➜ git_hug git:(master) git branch * master new-feature ➜ git_hug git:(master) git checkout new-feature Switched to branch 'new-feature' ➜ git_hug git:(new-feature) git log ➜ git_hug git:(new-feature) git checkout master Switched to branch 'master' ➜ git_hug git:(master) git cherry-pick ca32a6dac7b6f97975edbe19a4296c2ee7682f68 [master be39958] Filled in README.md with proper input Author: Andrey <aslushnikov@gmail.com> Date: Wed Mar 28 02:25:51 2012 +0400 1 file changed, 1 insertion(+), 2 deletions(-) ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
44
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Name: grep Level: 44 Difficulty: **
Your project's deadline approaches, you should evaluate how many TODOs are left in your code
➜ git_hug git:(master) git grep 'TODO' | wc -l 4 ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** How many items are there in your todolist? 4 Congratulations, you have solved the level!
Merge all commits from the long-feature-branch as a single commit.
➜ git_hug git:(master) git merge --squash long-feature-branch Squash commit -- not updating HEAD Automatic merge went well; stopped before committing as requested ➜ git_hug git:(master) ✗ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)
Successfully rebased and updated refs/heads/master. ➜ git_hug git:(master) git log ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
49
1 2 3 4 5
Name: bisect Level: 49 Difficulty: ***
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 是某一次 commit 引入的。使用 make test 可以测试项目,返回值是 0 的话表示测试通过,无 bug。要求找出引入 bug 的那个 commit。
git birect 的基本用法如下:
执行 git birect start,表示开始二分搜索;
找到任意一个有问题的 commit,标记一下这个版本。一般这种情况下当前版本都是有问题的,所以 git birect bad
找到任意一个没问题的 commit,标记一下这个版本。如 git birect good f608824888b83bbedc1f658be7496ffea467a8fb
当你至少标记了一个 good 和一个 bad 之后,就会看到类似于 Bisecting: 675 revisions left to test after this 的提示,告诉你你标记的两个版本之间有这么多个待测试的版本。
然后两者中间的那个版本会自动被 checkout,你要做的是测试一下这个版本有没有问题,并标记为 git birect good 或 bad
You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at f608824... First commit ➜ git_hug git:(f608824) make test ruby prog.rb 5 | ruby test.rb ➜ git_hug git:(f608824) git bisect good Bisecting: 9 revisions left to test after this (roughly 3 steps) [fdbfc0d403e5ac0b2659cbfa2cbb061fcca0dc2a] Another Commit ➜ git_hug git:(fdbfc0d) git bisect run make test running make test ruby prog.rb 5 | ruby test.rb Bisecting: 4 revisions left to test after this (roughly 2 steps) [18ed2ac1522a014412d4303ce7c8db39becab076] Another Commit running make test ruby prog.rb 5 | ruby test.rb make: *** [test] Error 1 Bisecting: 2 revisions left to test after this (roughly 1 step) [9f54462abbb991b167532929b34118113aa6c52e] Another Commit running make test ruby prog.rb 5 | ruby test.rb Bisecting: 0 revisions left to test after this (roughly 1 step) [5db7a7cb90e745e2c9dbdd84810ccc7d91d92e72] Another Commit running make test ruby prog.rb 5 | ruby test.rb 18ed2ac1522a014412d4303ce7c8db39becab076 is the first bad commit commit 18ed2ac1522a014412d4303ce7c8db39becab076 Author: Robert Bittle <guywithnose@gmail.com> Date: Mon Apr 23 06:52:10 2012 -0400
Another Commit
:100644 100644 917e70054c8f4a4a79a8e805c0e1601b455ad236 7562257b8e6446686ffc43a2386c50c254365020 M prog.rb bisect run success ➜ git_hug git:(5db7a7c) githug ******************************************************************************** * Githug * ******************************************************************************** What are the first 7 characters of the hash of the commit that introduced the bug? 18ed2ac1522 Congratulations, you have solved the level!
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.
➜ git_hug git:(master) ✗ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
modified: feature.rb
no changes added to commit (use "git add" and/or "git commit -a") ➜ git_hug git:(master) ✗ git add feature.rb -e
[删除第二个commit]
➜ git_hug git:(master) ✗ githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
51 - 56
51
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Name: find_old_branch Level: 51 Difficulty: ****
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.
➜ git_hug git:(kill_the_batman) git reflog ➜ git_hug git:(kill_the_batman) git checkout solve_world_hunger Switched to branch 'solve_world_hunger' ➜ git_hug git:(solve_world_hunger) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
52
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Name: revert Level: 52 Difficulty: ****
You have committed several times but want to undo the middle commit. All commits have been pushed, so you can't change existing history.
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 are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at ef65ada... Restore this commit ➜ git_hug git:(ef65ada) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
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.
➜ git_hug git:(master) git branch * master mybranch ➜ git_hug git:(master) git merge mybranch Auto-merging poem.txt CONFLICT (content): Merge conflict in poem.txt Automatic merge failed; fix conflicts and then commit the result. ➜ git_hug git:(master) ✗ git status On branch master You have unmerged paths. (fix conflicts and run "git commit")
Unmerged paths: (use "git add <file>..." to mark resolution)
both modified: poem.txt
no changes added to commit (use "git add" and/or "git commit -a") ➜ git_hug git:(master) ✗ vim poem.txt ➜ git_hug git:(master) ✗ git add poem.txt ➜ git_hug git:(master) ✗ git commit -m "solve conflict" [master 6ab8003] solve conflict ➜ git_hug git:(master) githug ******************************************************************************** * Githug * ******************************************************************************** Congratulations, you have solved the level!
55
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Name: submodule Level: 55 Difficulty: **
You want to include the files from the following repo: `https://github.com/jackmaney/githug-include-me` into a the folder `./githug-include-me`. Do this without manually cloning the repo or copying the files from the repo into this repo.
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.