git
version control
git push
commits
tags

Push git commits tags simultaneously

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

When you run git push, Git sends branch references, not tags, unless you ask for them explicitly. If you want your commits and release tags to arrive on the remote together, the safest approach is usually --follow-tags, with --tags reserved for the rarer case where you truly want every local tag pushed.

What git push Sends by Default

A normal branch push updates the branch ref on the remote:

bash
git push origin main

That command transfers any commits needed for main, but it does not automatically push tags that point to those commits. This surprises people during releases because the remote branch advances while the release tag remains local.

If you create annotated release tags, --follow-tags is the most practical one-command solution.

bash
git tag -a v1.4.0 -m "Release v1.4.0"
git push origin main --follow-tags

This does two useful things:

  • It pushes the branch update for main.
  • It also pushes annotated tags that are reachable from the commits being pushed.

That behavior is deliberate. It avoids flooding the remote with unrelated old tags while still covering the normal release workflow.

When to Use --tags

If you really need to push every local tag along with your branch update, use --tags:

bash
git push origin main --tags

Be careful with this form. It pushes all local tags, not just the one you created for the current release. In a repository with experimental or stale tags, that may be broader than you intended.

For a single specific tag, keep the push explicit:

bash
git push origin main
git push origin v1.4.0

That is two commands rather than one, but it is the clearest option when you want tight control.

Annotated vs Lightweight Tags

The difference matters because --follow-tags only follows annotated tags.

Annotated tag:

bash
git tag -a v1.4.0 -m "Release v1.4.0"

Lightweight tag:

bash
git tag v1.4.0

If you use the lightweight form, git push origin main --follow-tags will not send that tag. For release management, annotated tags are usually the better choice anyway because they preserve the tagger, date, and message.

A Practical Release Flow

A clean release sequence might look like this:

bash
1git status
2git log --oneline origin/main..HEAD
3git tag -a v1.4.0 -m "Release v1.4.0"
4git push origin main --follow-tags

Then confirm the remote state:

bash
git ls-remote --heads --tags origin

That extra verification step is useful in CI-heavy teams, where a missing tag can break packaging or deployment steps even though the branch push succeeded.

Pushing Multiple Branches with Tags

If you are pushing several refs at once, the same idea applies:

bash
git push origin main release/1.4 --follow-tags

Git will update both refs and include matching annotated tags reachable from the pushed commits. This is often enough for coordinated release branches.

Common Pitfalls

  • Assuming a normal branch push automatically carries release tags with it.
  • Using lightweight tags and expecting --follow-tags to push them.
  • Reaching for --tags in a repository where many local tags should stay private or unpublished.
  • Skipping remote verification even though downstream automation depends on the tag existing.
  • Treating tags like branch refs instead of separate refs with their own push behavior.

Summary

  • 'git push origin main pushes commits for the branch, not tags.'
  • 'git push origin main --follow-tags is the usual one-command release workflow.'
  • '--follow-tags works with annotated tags, not lightweight tags.'
  • 'git push origin main --tags pushes every local tag and should be used carefully.'
  • Verify remote heads and tags after a release push if the tag triggers downstream automation.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions