Actions

EmSys

Git - Tagging versions

From EdWiki

GitLab - Tagging versions

  • Goals
    Learn how to tag commits with names for future reference

Let’s call the current version of the hello program version 1 (v1).

  • Tagging version 1
git tag v1

Now you can refer to the current version of the program as v1.

  • Tagging Previous Versions

Let’s tag the version immediately prior to the current version v1-beta. First we need to checkout the previous version. Rather than lookup up the hash, we will use the ^ notation to indicate the parent of v1.

If the v1^ notation gives you any trouble, you can also try v1~1, which will reference the same version. This notation means "the first ancestor of v1".

git checkout v1^
cat hello.c

See, this is the version with the default value before we added the argv[1] output. Let’s make this v1-beta.

git tag v1-beta
  • Checking Out by Tag Name

Now try going back and forth between the two tagged versions.

git checkout v1
git checkout v1-beta
  • Viewing Tags using the tag command

You can see what tags are available using the git tag command.

git tag
  • Viewing Tags in the Logs

You can also check for tags in the log.

git hist master --all

You can see both tags (v1 and v1-beta) listed in the log output, along with the branch name (master). Also HEAD shows you the currently checked out commit (which is v1-beta at the moment).