The remote repositories have a url associated to them. Please enter the url of remote_location.这个远程仓库有一个与它相关的 URL,请输入远程仓库 remote_location 的 URL 地址。承上关,在 git remote 命令后面加一个 -v 参数就可以查询远程仓库的 URL 了。
This project has a remote repository. Identify it.这个项目有一个远程仓库,找出它。我们大部分时间都是在操作本地仓库,与远程仓库相关的命令也不多,比如前面的23关中,也只有第5、第6、第18关这3关涉及到了远程仓库。接下来的5关将集中学习有关远程仓库的知识。我们先来描述一下应用场景。
A file has been modified, but you don't want to keep the modification. Checkout the 'config.rb' file from the last commit.一个文件已被修改过,但你不想保留修改过的内容。从最后一次提交中 checkout 出 'config.rb' 文件。这还是一个撤销操作。
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).已经有2个文件即将被提交(即是已加入到暂存区),但为了把每个文件分别提交,需要把 'to_commit_second.
Commit your changes with the future date (e.g. tomorrow).把提交日期设定在未来的某一天(比如明天)。这关的任务很奇怪,要求把提交时间设定在未来,可是 Git 这台时光机只能开往过去不能开往未来,它只负责把发生过的事管理好,所以把提交时间设定在未来某个时间点实在没有道理啊!
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.已经提交了文件 'README',但忘记提交文件 'forgotten_file.rb' 了。修改前一次提交,把这个文件加进去。
There are tags in the repository that aren't pushed into remote repository. Push them now.本地仓库里有一些标签没有推送到远程仓库中,把它们推送到远程仓库。在默认情况下标签是不会被 git push 命令推送到远程服务器的,也就是说,你在本地打的标签,如果没有刻意指定把它推送到服务器,别人是看不到的。
We have a git repo and we want to tag the current commit with 'new_tag'.为仓库当前的提交增加一个名为 'new_tag' 的标签。把开发一个项目当作一次旅行,如果每个 commit(提交) 都是从窗外晃过的一根电线杆,那么 tag(标签) 就是可以停靠的车站,你可以选择一刻不停地开到终点,也可以歇下脚看看风景再继续前行。
You will be asked for the hash of most recent commit. You will need to investigate the logs of the repository for this.你将被询问最近一次提交的 hash 值,可以通过仓库日志找到它。本关考察的是对日志查询结果的阅读能力。
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.仓库中逐渐积累了一些文件,现在你意识到应该重新组织一下目录结构,请创建一个名为 'src' 的新目录名,用 Git 能追踪到方式把 .html 文件移到此文件夹中。
We have a file called 'oldfile.txt'. We want to rename it to 'newfile.txt' and stage this change.有一个名为 'oldfile.txt' 的文件,要把它改名为 'newfile.txt',并且把这个改动记录到暂存区。在第11关时我们曾用 git rm 来删除仓库里的文件,同样地,如果要对仓库里的文件改名,也不要直接用 mv 命令,而要用 git mv 命令,该命令会自动把改动记录到暂存区。
You've made some changes and want to work on them later. You should save them, but don't commit them.你修改了一个文件,但还没改完,这时你要保存它,而不是提交它。设想这样的场景:你正为一个类文件写一个新方法,写到一半了但还没写完,这时来了一个紧急任务,需要修改这个类的另一个方法,然后提交。
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 暂存区删除。
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.有一个文件被从工作目录中直接删除了,而没有通知到仓库,找到这个文件,把它从仓库中删除。
There are some files in this repository, one of the files is untracked, which file is it?仓库中有一个文件是未被 Git 管理的,请问是哪一个文件?Git 管理下的文件有多种状态,在工作中你经常需要先查询文件状态才能决定下一步做什么或怎么做,所以它的重要性和 Linux 的 ls 命令是一样重要的,是几乎所有操作的起点。
Notice a few files with the '.a' extension. We want git to ignore all but the 'lib.a' file.我们想忽略以 '.a' 为扩展名的文件,但不忽略 'lib.a' 这个文件。在上一关讲到的忽略规则中,最后一条是把某个文件排除在已有规则之外,正好用它来解这一关: