githug游戏通关记录

level 1

题目

Name: init
Level: 1
Difficulty: *
A new directory, git_hug, has been created; initialize an empty repository in it.

解答

git init

level 2

题目

Name: config
Level: 2
Difficulty: *
Set up your git name and email, this is important so that your commits can be identified.

解答

git config --global user.name "yourname"
git config --global user.email "youremail"

level 3

题目

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 add README

level 4

题目

Name: commit
Level: 4
Difficulty: *
The README file has been added to your staging area, now commit it.

解答

git commit            #随意输入值,然后ctrl+x,选择yes,最后回车

level 5

题目

Name: clone
Level: 5
Difficulty: *
Clone the repository at https://github.com/Gazler/cloneme.

解答

git clone https://github.com/Gazler/cloneme

level 6

题目

Name: clone_to_folder
Level: 6
Difficulty: *
Clone the repository at https://github.com/Gazler/cloneme to my_cloned_repo.

解答

 git clone https://github.com/Gazler/cloneme my_cloned_repo

level 7

题目

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.

解答

 vim .gitignore              #然后在这个文件夹最后添加一行*.swp

在这里插入图片描述

level 8

题目

Name: include
Level: 8
Difficulty: **
Notice a few files with the ‘.a’ extension. We want git to ignore all but the ‘lib.a’ file.

解答

 vim .gitignore              #然后在这个文件夹最后添加l两行,分别是*.a    !lib.a

在这里插入图片描述

level 9

题目

Name: status
Level: 9
Difficulty: *
There are some files in this repository, one of the files is untracked, which file is it?

解答

 git status

level 10

题目

Name: number_of_files_committed
Level: 10
Difficulty: *
There are some files in this repository, how many of the files will be committed?

解答

 git status
 githug
 2   #具体数值为你的游戏显示的数值

level 11

题目

Name: rm
Level: 11
Difficulty: **
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 status
git rm deleteme.rb

level 12

题目

Name: rm_cached
Level: 12
Difficulty: **
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 status
git rm --cached deleteme.rb

level 13

题目

Name: stash
Level: 13
Difficulty: **
You’ve made some changes and want to work on them later. You should save them, but don’t commit them.

解答

git stash

level 14

题目

Name: rename
Level: 14
Difficulty: ***
We have a file called oldfile.txt. We want to rename it to newfile.txt and stage this change.

解答

git mv oldfile.txt newfile.txt

level 15

题目

Name: restructure
Level: 15
Difficulty: ***
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.

解答

mkdir src
git mv *.html src/

level 16

题目

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 log
githug             #然后根据提示输入之前log打印出的哈希值,只需要前几位就行

level 17

题目

Name: tag
Level: 17
Difficulty: **
We have a git repo and we want to tag the current commit with new_tag.

解答

git tag new_tag

level 18

题目

Name: push_tags
Level: 18
Difficulty: **
There are tags in the repository that aren’t pushed into remote repository. Push them now.
From /tmp/d20191008-4409-1g3mqtz/
'* [new branch] master -> origin/master

解答

git push --tags

level 19

题目

Name: commit_amend
Level: 19
Difficulty: **
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 add forgotten_file.rb 
git commit --amend

level 20

题目

Name: commit_in_future
Level: 20
Difficulty: **
Commit your changes with the future date (e.g. tomorrow).

解答

git commit --date <date>     #例如今天是2019年10月8日,那么久写为  git commit --date 2019.10.09

level 21

题目

Name: reset
Level: 21
Difficulty: **
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 status

在这里插入图片描述
找到需要取消的文件后

git reset HEAD to_commit_second.rb 
git commit -m "finash"

level 22

题目

Name: reset_soft
Level: 22
Difficulty: **
You committed too soon. Now you want to undo the last commit, while keeping the index.

解答

git status
git reset --soft HEAD^1

level 23

题目

Name: checkout_file
Level: 23
Difficulty: ***
A file has been modified, but you don’t want to keep the modification. Checkout the config.rb file from the last commit.

解答

git status
git checkout config.rb

level 24

题目

Name: remote
Level: 24
Difficulty: **
This project has a remote repository. Identify it.

解答

git remote
my_remote_repo

level 25

题目

Name: remote_url
Level: 25
Difficulty: **
The remote repositories have a url associated to them. Please enter the url of remote_location.

解答

git remote -v
 https://github.com/githug/not_a_repo

level 26

题目

Name: pull
Level: 26
Difficulty: **
You need to pull changes from your origin repository.

解答

git remote -v
git pull origin master

level 27

题目

Name: remote_add
Level: 27
Difficulty: **
Add a remote repository called origin with the url https://github.com/githug/githug

解答

git remote add origin https://github.com/githug/githug

暂时就先写到这儿了,后面再慢慢补充

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值