← Learning Hub
Intermediate

.gitignore, Tags and Releases

.gitignore keeps files out of Git that shouldn't be shared - secrets, build output, installed packages. Tags mark important points in history, like released versions, so you can always find exactly what was shipped.

.gitignore: files Git should never track

Some files don't belong in a repository: installed packages, build output, secrets, editor settings, logs. List them in a .gitignore file at the top of the project.

Example
# .gitignore
node_modules/
dist/
.venv/
__pycache__/
*.log
.env
.DS_Store
.idea/
  • folder/ ignores a whole folder; *.log ignores every .log file.
  • !keep.log makes an exception.
  • GitHub offers ready-made templates for Node, Python, Java and more when you create a repo.
Example
# Already committed a file by mistake? Stop tracking it but keep it on disk:
git rm --cached .env
git commit -m "Stop tracking .env"

Tags and releases

A tag is a permanent name for one commit - usually a version number.

Example
git tag -a v1.0.0 -m "First public release"
git push origin v1.0.0
git tag                       # list tags
git switch --detach v1.0.0    # look at the code exactly as it was

On GitHub, Releases turn a tag into a page with notes and downloadable files.

Semantic versioning

  • MAJOR.MINOR.PATCH, e.g. 2.4.1
  • PATCH - bug fixes (2.4.2)
  • MINOR - new features that don't break anything (2.5.0)
  • MAJOR - changes that may break existing users (3.0.0)
Key points
  • .gitignore lists files Git should not track.
  • Never commit secrets like .env files.
  • Tags mark releases: git tag v1.0.

📝 Test yourself

1. Which file tells Git which files to ignore?
2. You fixed a bug in version 2.4.1. The new version is...
3. Fill in the command that stops tracking a file but keeps it on disk:
git rm .env