Press ESC to close · Ctrl+K to open

Git & GitHub for Teams:
Interactive Guide to Collaborative Workflows with VS Code

Git & GitHub - Collaborative workflow with VS Code

Choose how you want to follow this guide:

0 of 6 scenarios completed

Meet the team

In this tutorial, we'll work with a team of 3 developers collaborating on a project from VS Code. Each one has their own workflow but they all share the repository on GitHub.

A
Ana Lead Developer
B
Bruno Backend Dev
C
Carlos Frontend Dev

1. Clone and set up the repository

The first thing every team member does

Each developer clones the GitHub repository to their local machine and configures their Git identity. In VS Code, this can be done from the integrated terminal or the graphical interface.

# Set up identity (first time only)
$ git config --global user.name "Ana García"
$ git config --global user.email "ana@company.com"

# Clone the repository
$ git clone https://github.com/team/project.git
$ cd project
$ code .
Tip: Running code . opens VS Code directly in the project folder.
  1. Ctrl+Shift+P → Type "Git: Clone" and press Enter
  2. Paste the repository URL: https://github.com/team/project.git
  3. Choose the destination folder and confirm
  4. VS Code will ask to open the repository → Open
☁️ GitHub (remote) git clone 💻 Local (your PC) Each developer clones: 👩‍💻Ana → git clone 👨‍💻Bruno → git clone 👨‍💻Carlos → git clone

2. Create branches

Each person works on their own branch

Golden rule: Never work directly on main. Each new feature or fix is developed on an independent branch. This way one person's work doesn't interfere with anyone else's.

📋
Issue / Task
A task is assigned in GitHub Issues
🌿
Create branch
Branch from main with descriptive name
💻
Develop
Code and make commits
🚀
Push + PR
Push and open Pull Request
# Ana creates a branch for the login system
$ git checkout -b feature/login

# Bruno creates a branch for the data API
$ git checkout -b feature/data-api

# Carlos creates a branch for the dashboard
$ git checkout -b feature/dashboard
Naming convention: Use prefixes like feature/, bugfix/, hotfix/ to organize your branches. Example: feature/login-oauth, bugfix/fix-header-overlap.
main feature/login (Ana) 👩‍💻 feature/data-api (Bruno) 👨‍💻 merge merge
In VS Code: You can create branches from the bottom bar (click on the current branch name) or with Ctrl+Shift+P → "Git: Create Branch".

3. Commit, Push and the daily workflow

The basic Git work cycle

The daily workflow with Git consists of: edit files → stage changes → commit → push to remote. In VS Code this is extremely visual and intuitive.

✏️
Edit
Modify files
📂
Stage
git add
📸
Commit
git commit
⬆️
Push
git push
☁️
GitHub
Synchronized
# See which files have changed
$ git status

# Add files to the staging area
$ git add src/login.js
$ git add . # or add ALL

# Create a commit with a descriptive message
$ git commit -m "feat: add login form with validation"

# Push to remote (first time on this branch)
$ git push -u origin feature/login

# Push subsequent changes (after the first time)
$ git push
  1. Open the Source Control panel with Ctrl+Shift+G
  2. Modified files appear under "Changes". Click + to stage them
  3. Write the commit message in the top text field
  4. Press ✓ Commit (or Ctrl+Enter)
  5. Click Sync Changes (or the ↑ icon) to push
Working Dir Edited files Staging Area git add Local Repo git commit Remote (GitHub) git push
Commit messages: Use Conventional Commits: feat:, fix:, docs:, refactor:, test:. It helps automate changelogs and understand the history.

4. Pull Requests and Code Review

The gateway to main

When you finish your work on a branch, you do NOT merge directly. You open a Pull Request (PR) on GitHub so your teammates can review the code before integrating it into main.

  1. Push your branchgit push -u origin feature/login
  2. Go to GitHub — A yellow banner "Compare & pull request" appears → click it
  3. Fill in the PR — Descriptive title, description of changes, screenshots if visual
  4. Assign reviewers — Select teammates for review
  5. Code Review — Reviewers comment, suggest changes, approve
  6. Merge — If everything is approved, merge to main
feature/login 🔀 Pull Request #12 "feat: login system" 👀 Code Review Bruno reviews the changes ✅ Approved → Merge main merge commit
In VS Code: Install the GitHub Pull Requests extension to manage PRs directly from the editor without going to the browser.

5. Resolving conflicts

When two people edit the same file

Conflicts occur when two branches modify the same lines of the same file. Git can't decide which one is correct, so it asks you to resolve it manually. Don't panic! VS Code makes this very visual and easy.

👩‍💻 Ana (feature/login)
// config.js
const PORT = 3000;
const HOST = 'localhost';
👨‍💻 Bruno (feature/data-api)
// config.js
const PORT = 8080;
const HOST = '0.0.0.0';

⬇️ When trying to merge, Git shows this:

<<<<<<< HEAD (your branch) const PORT = 3000; const HOST = 'localhost'; ======= const PORT = 8080; const HOST = '0.0.0.0'; >>>>>>> feature/data-api

How to resolve in VS Code:

  1. VS Code shows conflicts with colors and buttons: Accept Current | Accept Incoming | Accept Both | Compare
  2. Choose which version to keep, or manually edit to combine both
  3. Delete the conflict markers (<<<, ===, >>>)
  4. Save the file → git addgit commit
# After resolving the conflicts manually:
$ git add config.js
$ git commit -m "fix: resolve conflict in config.js (merge feature/data-api)"
Never do this: Delete someone else's code without consulting them. Conflicts are for negotiating, not imposing. Talk to your teammate if you're not sure which version to keep.

6. Syncing with the team

git pull, fetch and rebase

While you work on your branch, your teammates may have merged changes to main. It's important to update your branch to avoid falling behind and minimize future conflicts.

# Pull changes from main and merge into your branch
$ git checkout feature/login
$ git pull origin main
Creates a merge commit that joins both histories. The history looks "messier" but it's safer.
# Rebase: rewrite your branch ON TOP of updated main
$ git checkout feature/login
$ git fetch origin
$ git rebase origin/main
Be careful with rebase: It rewrites history. Never rebase branches that are already shared with others. Only on local or personal branches.
Merge (real history) merge commit Rebase (linear history) rebased commits → Clean history, single line

Git Simulator — Practice here

Type Git commands and see what happens. Try: git init, git branch, git status, git log, help

Welcome to the interactive Git simulator.
Type 'help' to see available commands.

Cheat Sheet — Essential commands

Setup

git config --global user.name "Your Name" git clone <url> Configure identity and clone repositories.

Branches

git branch git checkout -b feature/new git switch main List, create and switch branches.

Daily flow

git add . git commit -m "message" git push Stage, commit and push to remote.

Sync

git pull git fetch git rebase origin/main Fetch team changes.

Inspect

git status git log --oneline --graph git diff View status, history and differences.

Undo

git restore <file> git reset HEAD~1 git stash Revert changes and save temporary work.