DG
DevGuide
Run Code
Home/Git & GitHub/Daily Git Workflow
⌥ Git & GitHub1 / 1

Daily Git Workflow

📌 WHAT

Git is a distributed version control system that tracks changes to your code over time. GitHub hosts your Git repositories online and enables team collaboration.

💡 WHY

Never lose work. See every change ever made. Collaborate with a team without overwriting each other's work. Required at every software company.

⏰ WHEN / WHERE

Every day you write code. Commit often (after each small working change). Branch for each feature. PR to merge back to main.

🔧 HOW

The flow: pull → branch → code → add → commit → push → pull request. Use descriptive commit messages.

Code Examples

#1Complete daily workflow

Complete daily workflow
bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# ============================================
# FIRST TIME: Clone repository
# ============================================
git clone https://github.com/company/project.git
cd project
# ============================================
# DAILY WORKFLOW
# ============================================
# Step 1: Always start by pulling latest changes
git pull origin main
# Step 2: Create a new branch for your feature/fix
git checkout -b feature/user-authentication
# Naming conventions:
# feature/feature-name — new functionality
# fix/bug-description — bug fixes
# chore/task-name — maintenance, deps
# hotfix/issue — urgent production fix
# Step 3: Write your code...
# ...
# Step 4: See what changed
git status # see changed files
git diff # see exact line changes
git diff src/components/Button.tsx # specific file
# Step 5: Stage changes
git add . # stage everything
git add src/components/Button.tsx # stage specific file
git add -p # interactively stage chunks
# Step 6: Commit with descriptive message
git commit -m "feat: add user authentication with Supabase"
# Good commit message format:
# type(scope): description
# feat: new feature
# fix: bug fix
# docs: documentation
# style: formatting
# refactor: code change without behavior change
# chore: build/dependency updates
# Step 7: Push your branch
git push origin feature/user-authentication
# Step 8: Open a Pull Request on GitHub
# Then: teammate reviews → comments → approve → merge
# ============================================
# OTHER USEFUL COMMANDS
# ============================================
git log --oneline # see commit history (compact)
git stash # save uncommitted changes temporarily
git stash pop # restore stashed changes
git diff main # compare your branch to main
git merge main # bring main changes into your branch
git rebase main # replay your commits on top of main (cleaner)
# Undo last commit (keep changes staged)
git reset --soft HEAD~1
# Discard all local changes (CAREFUL: irreversible!)
git checkout -- .

Practice This Concept

Open the playground, paste any example, and experiment. The best way to learn is by breaking things.

Open in Playground