PhpStorm 2018.1 Help

Use tags to mark specific commits

Git allows you to attach tags to commits to mark some points in the project history as being important, so that you can refer to them in the future. For example, you can tag a commit that corresponds to a release version, instead of creating a branch to capture a release snapshot.

Assign a tag to a commit

  1. From the main menu, choose VCS | Git | Tag.
  2. In the Tag dialog that opens, under Git Root, select the path to the local repository in which you want to tag a commit, and specify the name of the new tag.
  3. In the Commit field, specify the commit that you want to tag. You can enter the commit hash, or use an expression, for example: <branch>~<number of commits backwards between the latest commit (HEAD) and the required commit> (Refer to Git commit naming conventions for details).
  4. If you enter some comment in the Message field, an annotated tag will be created instead of a regular one. Meta-data for annotated tags contains the name of the user who created them, so they allow you to check who placed them.
  5. Click Create Tag. The tag will be shown in the Log view:
    tagged commit

Reassign an existing tag

If you've placed a tag on a wrong commit, and want to reassign it (for example, to indicate a commit for a release version), do the following:

  1. From the main menu, choose VCS | Git | Tag.
  2. In the Tag dialog, in the Tag Name field specify the name of an already existing tag that you want to reassign.
  3. Select the Force option.
  4. In the Commit field, specify the commit where the tag shall be moved and click Create Tag.

Jump to a tagged commit

  1. Open the Version Control tool window (Alt+9) and switch to the Log tab.
  2. Click the Go To Hash/Branch/Tag icon find on the toolbar, or press Ctrl+F.
  3. Enter the tag name (code completion suggests tag names as you type) and press Enter.

Check out a tagged commit

Suppose you marked a commit that corresponds to a release version with a tag, and now you want to review the snapshot of your project at that point in time. You can do this by checking out a tagged commit. Do one of the following:

  • Locate the tagged commit that you want to checkout, right-click it and select Checkout Revision from the context menu.
  • Invoke the branches popup, click Checkout Tag or Revision and type in the tag name.

Note that this operation results in a detached HEAD, which means you are no longer in any branch. You can use this snapshot for inspection and experiments. However, if you want to commit changes on top of this snapshot, you will need to create a branch.

Last modified: 27 July 2018