让我们叫 hello 程序的当前版本为 version 1 (v1)。
现在你可以引用程序的当前版本为 v1。
如果使用 v1^
表示法遇到问题,那么你也可以试试 v1~1
, 这将引用相同的版本。该表示法意为“v1 的第一个祖先提交”。
$ git checkout v1^
$ cat hello.rb
$ git checkout v1^
Note: checking out 'v1^'.
You are in 'detached HEAD' state. You can look around, make experimental
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 582495a... Added a default value
$ cat hello.rb
name = ARGV.first || "World"
看,这是我们添加注释之前的默认值版本。让我们使它成为 v1-beta。
$ git checkout v1-beta
$ git checkout v1
Previous HEAD position was 582495a... Added a default value
HEAD is now at 1f7ec5e... Added a comment
$ git checkout v1-beta
Previous HEAD position was 1f7ec5e... Added a comment
HEAD is now at 582495a... Added a default value
你可以使用 git tag
命令来看看可用的标签有什么。
$ git tag
v1
你也可以检查日志中的标签。