Git is version control. It tracks changes in your code so you can experiment, review history, collaborate, and recover from mistakes.
Every professional Android developer should be comfortable with Git basics.
The Core Workflow
Most daily Git work follows this flow:
git status
git add .
git commit -m "Add login screen"
git push
git status shows what changed. git add stages changes. git commit saves a snapshot. git push uploads commits to a remote repository.
Branches
Branches let you work without disturbing the main codebase.
git switch -c feature/login-screen
git switch is the modern command for branch operations. git checkout still works but git switch is clearer about intent.
After finishing the work, push the branch and open a pull request.
git push origin feature/login-screen
To switch between existing branches:
git switch main
git switch feature/login-screen
Reading Diffs
Before committing, inspect your changes.
git diff
git diff --staged
This habit catches accidental edits, debug logs, formatting noise, and secrets.
Good Commit Messages
Use messages that explain the change:
Add login form validationFix crash when lesson list is emptyRefactor profile screen state
Avoid vague messages like changes, fix, or update.
The .gitignore File
A .gitignore file tells Git which files and folders to never track. Android projects should ignore build outputs, IDE settings, and local config files.
Android Studio creates a .gitignore when you start a project. Make sure it contains at least:
build/
.gradle/
local.properties
*.jks
*.keystore
local.properties contains your local SDK path. Keystore files contain your signing keys. Neither should ever be committed to a shared repository.
Common Beginner Mistakes
| Mistake | Fix |
|---|---|
| Committing generated build files | Use .gitignore |
| Huge unrelated commits | Commit focused changes |
| Not pulling before starting work | Sync regularly |
| Ignoring conflicts | Read both sides carefully |
Practice
Create a branch, edit a README file, commit the change, inspect the log, then create another branch and switch between them.
Summary
Git is part of the job, not an optional tool. Learn status, add, commit, branch, diff, pull, push, and conflict resolution early.