Tags mark a specific commit at a point in your repository history. When you tag a commit, you're including all the changes before it. You can later compare tags to see the difference between two points in history. Tags are commonly used to mark release versions, with the release name as the tag name.
Bitbucket Cloud supports tags for Git repositories. You can create a tag in Bitbucket or locally and push it to Bitbucket.
Create a tag in Bitbucket
- From your Bitbucket repository, click the link for the commit you want to tag.
- In the details on the right side of the page, click the button.
- Enter a Tag name and click Create tag.
Removing a tag
You can't remove a tag from Bitbucket after you've added it. To remove a tag, you'll have to do so from the command line. Refer to Tags for Git repositories for these commands.
See the commits for a tag
- Click the Commits link the left panel.
- Click the dropdown at the top of the page.
- Click the Tags tab.
- Search for and click the tag you want to see. The Commits list updates with all the commits for that tag.
Create and push a tag to Bitbucket
You can create tags locally for your Git repositories. Depending on the type of tag you create, they'll appear in Bitbucket anywhere that lists your tags for a commit.
Tags for Git repositories
While Git supports annotated and lightweight tags, you can only create and see annotated tags in Bitbucket. Git stores annotated tags as full objects in the repository, which means they include the name, email, date, and have a message. Lightweight tags don't include all this additional information.
Use the following commands to create, push, and perform other tagging options for Git repositories.
|Tag task||Git commands|
|Create an annotated tag|
git tag -a <tag_name> -m '<tag_message>'
|Create a lightweight tag|
git tag <tag_name>
|Push all your tags (a regular push won't push a tag)|
git push origin --tags
|Push a single tag|
git push origin : <tag_name>
|List the tags in a repository|
|Remove a tag from a repository|
git tag -d <tag_name>
git push origin :refs/tags/<tag_name>
Compare the diffs with tags
Once you've got at least one tag, you can compare that tag with another tag or a branch.
- Click + in the global sidebar and select Compare branches or tags under Get to work.
- From each dropdown, select the tag or branch that you want to include as part of the comparison.
- Click Compare.
You'll see a diff, a list of commits, and any pull requests merged between the two versions.