You have committed several times but in the wrong order. Please reorder your commits.你提交过几次,但是提交的顺序错了,请调整提交顺序。在第44关和第45关我们使用 git rebase -i 命令修改了历史日志的提交说明、把多次提交合并成了一次,在本关,我们要用这个命令来调整提交顺序。
Merge all commits from the long-feature-branch as a single commit.把名为 long-feature-branch 的分支合并到主干,把分支中的多次提交合并为主干上的一次提交。在第38关我们曾学习过 merge 合并,它的语法是:$ git merge branch-name如果分支曾经提交过多次,那么用上面的语句合并之后,主干的日志也会出现多次提交记录。
You have committed several times but would like all those changes to be one commit.你提交过几次,但是现在想把这些提交合并成一次提交。承上关,如果要把多次合并合并成一次提交,可以用 git rebase -i 的 squash 命令。
Correct the typo in the message of your first (non-root) commit.在第一次提交时有一个拼写错误,修正它。在使用 Git 的过程中,难免会出现要改写提交内容的情况,Git 提供了非常强大的修改历史的工具,我们就以本关为例,详细说明如何修改历史,并在接下来的第45关和第47关再做另外2个练习。
Your project's deadline approaches, you should evaluate how many TODOs are left in your code.项目的交付时间快到了,你要评估一下代码里还遗留了多少待办事项。和 Linux 的 grep 命令类似,Git 也提供了一个用于搜索文本的 grep 命令:$ git grep keyword$ git grep keyword file-name第1条命令在当前项目下查找指定的关键词;
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.你在新功能上的努力白废了,准备删除掉它,但是往 'README' 文件里填充内容的那次提交还有用,你要把这次提交合并到主线上。
Optimise how your repository is packaged ensuring that redundant packs are removed.优化你的仓库,重新打包,并清除多余的包。在第1关里我们提到,当 Git 项目初始化时,会创建一个隐藏的名为 .git 的子目录,用于存放 Git 管理仓库要用到的文件。在 Git 的世界里,一个文件是一个 Git 对象,一次提交也是一个 Git 对象,它们被存储在 .git/objects/ 目录下:$ ls .
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 rebase 工作流,feature 分支准备合并到 master。rebase 这个 feature 分支到我们的 master 分支之上。在第28关我们曾经使用过一次 git rebase 命令,现在我们再详细讲解一下。
Looks like a new branch was pushed into our remote repository. Get the changes without merging them with the local repository 看起来好像有新的分支推送到了远程仓库。得到新的修改而不要合并到本地仓库。在第26关我们曾用 git pull 把远程仓库的更新拉到本地仓库,这个命令其实隐含了2个连续的动作,即 git fetch 和 git merge。
We have a file in the branch 'feature'; Let's merge it to the master branch.你有一个文件在分支 'feature',把它合并到 master 分支。当我们在分支完成修改和测试之后,就可以把分支合并到主线上了,它的命令是:$ git merge branch-name执行这条命令之前,要先切换到主线(一般是 master 分支),然后把待合并的分支名作为参数。
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.你的一个本地分支有一些修改,你想把它分享出去,但又不想合并到 master 分支上。仅把 'test_branch' 推送到远程仓库。
You have created too many branches for your project. There is an old branch in your repo called 'delete_me', you should delete it.你为这个项目创建了太多的分支。有一个旧分支名为 'delete_me',删除掉它。删除分支的命令如下:$ git branch -d branch-name和创建分支的区别在于增加了一个 -d 参数。第36关过关画面如下:
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.你忘记了在上一个提交之间先创建一个分支就提交了。创建一个分支 test_branch 在最后一次提交之前。
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).你要在 1.2 版本中修复一个 bug,切换到 tag 'v1.2'(注意:现在有一个分支也叫 'v1.2')。如果存在一个和分支同名的 tag,比如都叫 'v1.2',那么当执行 git checkout v1.2 命令时,是该切换到分支,还是该切换到 tag 呢?答案是切换到分支。
You need to fix a bug in the version 1.2 of your app. Checkout the tag v1.2.你要在 1.2 版本中修复一个 bug,切换到 tag 'v1.2'。在第17关我们学习了如何创建 tag,tag 是一个有语义的标签,便于记忆,我们可以把版本号或其他有特定含义的词语作为 tag。
Create and switch to a new branch called my_branch. You will need to create a branch like you did in the previous level.创建并切换到新分支 my_branch。你要像上一关那样先创建一个分支。上一关我们创建了分支,但是还没有切换到新分支上。如果你仔细观察,会发现 git branch 语句的结果中,在 master 前面有一个 * 号,它表示当前你所在的分支。
You want to work on a piece of code that has the potential to break things, create the branch test_code.你想要修改一处代码,在修改过程中可能会引起一些问题,所以要创建一个分支 test_code 来修改。接下来的10关都和分支有关。如果你想在不影响主线的情况下进行安全的开发,就要以主线为基础创建一个分支,然后在分支上修改,最后再把分支合并到主线上。
Someone has put a password inside the file 'config.rb' find out who it was.有人在 'config.rb' 中植入了一个密码,请找出这是谁干的。当系统曝出 bug 或者漏洞,要查清问题的来源时,首先定位问题代码,其次定位是谁引入了错误。
Your local master branch has diverged from the remote origin/master branch. Rebase your commit onto origin/master and push it to remote.你本地仓库的代码是由远程仓库的 origin/master 分支创建的。rebase 你的更新到 origin/master,然后提交到远程仓库。