让我们叫 hello 程序的当前版本为 version 1 (v1)。

    现在你可以引用程序的当前版本为 v1。

    如果使用 v1^ 表示法遇到问题,那么你也可以试试 v1~1, 这将引用相同的版本。该表示法意为“v1 的第一个祖先提交”。

    1. $ git checkout v1^
    2. $ cat hello.rb
    1. $ git checkout v1^
    2. Note: checking out 'v1^'.
    3. You are in 'detached HEAD' state. You can look around, make experimental
    4. state without impacting any branches by performing another checkout.
    5. If you want to create a new branch to retain commits you create, you may
    6. do so (now or later) by using -b with the checkout command again. Example:
    7. git checkout -b new_branch_name
    8. HEAD is now at 582495a... Added a default value
    9. $ cat hello.rb
    10. name = ARGV.first || "World"

    看,这是我们添加注释之前的默认值版本。让我们使它成为 v1-beta。

    1. $ git checkout v1-beta
    1. $ git checkout v1
    2. Previous HEAD position was 582495a... Added a default value
    3. HEAD is now at 1f7ec5e... Added a comment
    4. $ git checkout v1-beta
    5. Previous HEAD position was 1f7ec5e... Added a comment
    6. HEAD is now at 582495a... Added a default value

    你可以使用 git tag 命令来看看可用的标签有什么。

    1. $ git tag
    2. v1

    你也可以检查日志中的标签。