
However, if you want to commit changes on top of this snapshot, you will need to create a branch.



You can use this snapshot for inspection and experiments. Note that this operation results in a detached HEAD, which means you are no longer in any branch. Invoke the branches popup, click Checkout Tag or Revision and type in the tag name (IntelliJ IDEA provides a list of matching tags and revisions as you type). Locate the tagged commit that you want to checkout, right-click it and select Checkout Revision from the context menu. You can do this by checking 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.
Git checkout commit code#
In the Commit field, specify the commit where the tag shall be moved and click Create Tag.Ĭlick the Go To Hash/Branch/Tag icon on the toolbar, or press Ctrl+F.Įnter the tag name ( code completion suggests tag names as you type) and press Enter. In the Tag dialog, in the Tag Name field specify the name of an already existing tag that you want to reassign. 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: You can also right-click a commit in the Log tab of the Version Control tool window Alt+9 and select New Tag from the context menu if you do not need to specify any additional options. If the Compact References View option is enabled under Quick Settings in the Log toolbar, tag names are hidden behind branch names and are not visible. You can enter the commit hash, or use an expression, for example: ~ (Refer to Git commit naming conventions for details).Įnter some comment in the Message field to create an annotated tag (if it's empty, a regular tag will be created). In the Commit field, specify the commit that you want to tag. 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. Meta-data for annotated tags contains the name of the user who created them, so they allow you to check who placed them.įrom the main menu, choose Git | New Tag. The tag will be shown in the Log tab of the Git tool window Alt+9: Locate the commit you want, right-click it and select New Tag from the context menu.Įnter the name of the new tag and click OK. Open the Git tool window Alt+9 and switch to the Log tab. For example, you can tag a commit that corresponds to a release version, instead of creating a branch to capture a release snapshot. Now you have successfully created a new branch from a commit in the commit history.Git allows you to attach tags to commits to mark certain points in the project history so that you can refer to them in the future. * ecddf76 (HEAD -> feature-104) Feature 1 added. Use 'git log' command again to make sure that the new branch is created from the correct commit SHA $ git log -oneline -graph Now let's assume you want to create a branch from the second commit with commit hash value 'ecddf76'. Now you can see 3 commits in the git history. * 34cd5ff (new-branch, develop) Test commit. Use ‘git log’ command with ‘-online’ and ‘-graph’ options to get the commit SHA.

The first step is to find the commit SHA from which you want to create the branch. Here are the detailed steps to create a GIT branch from a commit hash with the git checkout command: 1. Or, you can also use the 'git branch' command to create the branch without switching to the new branch. GIT branch can be created with a commit hash using the ‘git checkout’ command with ‘-b’ option and then pass a new branch name with the commit SHA. But what if you want to create a branch from a previous commit HEAD? Usually, a branch is created from another branch which is the latest HEAD commit of the branch.
