Friday, 7 November 2025

Git - release in git

release” in Git (and GitHub) usually refers to a stable, packaged version of your project that’s ready to use so that it can be used by customers or other developers.

The underlying technology that makes a release possible in Git is the Git Tag.

A tag is a permanent, fixed reference (like a label) to a specific commit in your repository's history. Unlike branches, which move forward with new commits, a tag always points to the exact same commit forever.

Command: You create a tag using the git tag command, usually following Semantic Versioning (SemVer) (e.g., v1.0.0, v2.1.5).

# Create an annotated tag (recommended for releases) git tag -a v1.0.0 -m "Initial stable release" # Push the tag to the remote repository git push origin v1.0.0 

In Git, tags are mainly of two types:

1️⃣ Lightweight Tag

  • Think of it as a bookmark to a specific commit.

  • Just points to a commit without any extra metadata.

  • No author, date, or message attached.

Example:

git tag v1.0
  • v1.0 now points to the current commit.

  • Quick and simple, but not ideal for release notes or annotations.


2️⃣ Annotated Tag

  • A full-fledged tag stored as a Git object.

  • Can contain:

    • Tagger name & email

    • Date

    • Message

    • Can be signed with GPG for verification

Example:

git tag -a v1.0 -m "Release version 1.0"
  • -a → annotated tag

  • -m → tag message

You can see details with:

git show v1.0

💡 Common Release Assets (Binaries)

Desktop Software .exe file (Windows installer), .dmg file (macOS), .deb or .rpm package (Linux).


Web/Library A pre-compiled .zip or .tar.gz file containing the minified JavaScript/CSS, or a pre-built static site.


Game The final, compiled game folder or installer.


Simple Script/Tool A bundled .jar file, a Python wheel (.whl), or a compiled single binary.


As I was using /var/www/html as my git repository and The standard way to create a .tar.gz archive (also known as a "tarball") for your Apache web directory on Linux is by using the tar command with the appropriate flags.


[root@devopsvm01 html]# tar -czvf web_backup_$(date +%Y%m%d).tar.gz /var/www/html/

tar: Removing leading `/' from member names

/var/www/html/

/var/www/html/about.html

/var/www/html/index.html

/var/www/html/.git/

/var/www/html/.git/branches/

/var/www/html/.git/hooks/

.

.

/var/www/html/.git/ORIG_HEAD

/var/www/html/.git/REBASE_HEAD

/var/www/html/.git/COMMIT_EDITMSG

/var/www/html/main.html

/var/www/html/services.html

/var/www/html/news.html

/var/www/html/product.html

/var/www/html/offer.html

/var/www/html/web_backup_20251103.tar.gz

[root@devopsvm01 html]#


Get the web_backup_20251103.tar.gz to your local PC.


user@DESKTOP-0AVRJL4 MINGW64 ~/Downloads

$ scp root@192.168.0.222:/var/www/html/web_backup_20251103.tar.gz .

The authenticity of host '192.168.0.222 (192.168.0.222)' can't be established.

ED25519 key fingerprint is SHA256:zoi5Ra/kqhxDCOC67Th8169lRa5t8vqZ2i4tKCfzWJA.

This key is not known by any other names.

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Warning: Permanently added '192.168.0.222' (ED25519) to the list of known hosts.

root@192.168.0.222's password:

web_backup_20251103.tar.gz                    100%   57KB   3.7MB/s   00:00

user@DESKTOP-0AVRJL4 MINGW64 ~/Downloads

$

Now login to github and create release .



















We can create tag either locally or from UI console.



























I named tag as My-web-v1.0.0 and select the branch (ideally main)

























Now attach the tar file that we created earlier and click Publish release.
























Once published, you will get more details 



















Others will be able to access the latest codebase and deploy it wherever they need.

https://github.com/mahekarthya/devops-demo-pvt/releases/download/My-web-v1.0.0/web_backup_20251103.tar.gz


Why your local git tag doesn’t show the tag

  1. You created the tag on the remote (e.g., GitHub web UI).

  2. Your local repo doesn’t know about new remote tags until you fetch them.

  3. git tag by default only lists local tags, not remote tags.


How to see remote tags locally

  1. Fetch all tags from remote

git fetch --tags
  • This will download all tags from the remote and add them to your local repo.

  1. Verify tags

git tag
  • Now your locally created tags (from remote) should appear.

Example

[root@devopsvm01 html]# git tag
[root@devopsvm01 html]#
[root@devopsvm01 html]# git fetch --tags

remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (1/1), 906 bytes | 906.00 KiB/s, done.
From github.com:mahekarthya/devops-demo-pvt
   c3f57f8..8642505  main          -> origin/main
 * [new tag]         My-web-v1.0.0 -> My-web-v1.0.0
[root@devopsvm01 html]#
[root@devopsvm01 html]# git tag
My-web-v1.0.0
[root@devopsvm01 html]#


Optional: Checkout a tag

If you want to work on that release tag:

git checkout <tag_name>
  • Example:

git checkout v1.0
  • This will put your repo in a detached HEAD state, meaning you are not on any branch — just viewing that commit.


No comments:

Post a Comment

Building a Safer PostgreSQL CI/CD Pipeline with GitHub Actions: Dev → PR Review → Test Promotion

In my previous post, we explored a simple push-to-main deployment strategy . While functional, that model is not considered an industry best...