Dev Logs
/Git & GitHub/ Pull Requests and Code Review
Chapters
  • 01Git and GitHub Introduction
  • 02Basic Git Commands
  • 03Remote Repositories and GitHub
  • 04Branching Basics
  • 05Git Merge vs Rebase
  • 06Git Stash
  • 07Git Diff and Log
  • 08Resolving Merge Conflicts
  • 09Pull Requests and Code Review
    • What is a Pull Request?
    • Pull Request Workflow
    • Creating Your First Pull Request
    • Step 1: Prepare Feature Branch
    • Step 2: Push Branch to GitHub
    • Step 3: Create Pull Request on GitHub
    • Code Review Process
    • As a Reviewer
  • 10Question about implementation
  • 11Positive feedback
  • 12Security concern
  • 13Forking and Upstream Remotes
  • 14Advanced Git Rebase
  • 15Git Cherry-pick
  • 16Git Reset Deep Dive
  • 17Git Reflog Recovery
  • 18Git Bisect Bug Hunting
  • 19Git Tags
  • 20Git Hooks
  • 21Add hooks to version control
  • 22Conventional Commits
  • 23Update README
  • 24Conventional Commits Demo
  • 25GitHub CLI (gh)
  • 26GitHub Actions Basics
  • 27Maintaining Clean Git History in Teams
  • 28Branching Strategies: Git Flow vs Trunk-Based Development
  • 29Force Push Safety: Using --force-with-lease
All chapters

Pull Requests and Code Review

Pull Requests (PRs) are GitHub's mechanism for proposing changes, facilitating code review, and managing collaborative development. They're essential for maintaining code quality and team coordination.

What is a Pull Request?

A Pull Request is a request to merge changes from one branch into another. It provides:

  • Code Review: Team members can review changes before merging
  • Discussion: Comments and suggestions on specific lines
  • Testing: Automated tests run on proposed changes
  • Documentation: Clear description of what changes do
  • History: Permanent record of why changes were made

Pull Request Workflow

1. Create feature branch
2. Make changes and commit
3. Push branch to GitHub
4. Create Pull Request
5. Code review and discussion
6. Address feedback
7. Merge when approved
8. Clean up branches

Creating Your First Pull Request

Step 1: Prepare Feature Branch

bash
# Start from updated main branch
cd portfolio-website
git checkout main
git pull origin main

# Create feature branch
git checkout -b feature/add-projects-section

# Add projects section to portfolio
cat > projects.html << EOF
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Projects - John Doe</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <nav>
            <a href="index.html">Home</a>
            <a href="about.html">About</a>
            <a href="projects.html">Projects</a>
            <a href="contact.html">Contact</a>
        </nav>
    </header>
    <main>
        <h1>My Projects</h1>
        <div class="projects-grid">
            <article class="project-card">
                <h3>E-commerce Website</h3>
                <p>Full-stack e-commerce solution built with React and Node.js</p>
                <div class="tech-stack">
                    <span>React</span>
                    <span>Node.js</span>
                    <span>MongoDB</span>
                </div>
                <a href="#" class="project-link">View Project</a>
            </article>
            <article class="project-card">
                <h3>Task Management App</h3>
                <p>Collaborative task management tool with real-time updates</p>
                <div class="tech-stack">
                    <span>Vue.js</span>
                    <span>Express</span>
                    <span>Socket.io</span>
                </div>
                <a href="#" class="project-link">View Project</a>
            </article>
            <article class="project-card">
                <h3>Weather Dashboard</h3>
                <p>Responsive weather application with location-based forecasts</p>
                <div class="tech-stack">
                    <span>JavaScript</span>
                    <span>API Integration</span>
                    <span>CSS Grid</span>
                </div>
                <a href="#" class="project-link">View Project</a>
            </article>
        </div>
    </main>
    <footer>© 2024 John Doe</footer>
</body>
</html>
EOF

# Add CSS for projects
cat >> style.css << EOF

/* Projects Section */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.project-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.project-card h3 {
    color: #333;
    margin-bottom: 1rem;
}

.project-card p {
    color: #666;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tech-stack span {
    background: #007bff;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.project-link {
    display: inline-block;
    background: #28a745;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.project-link:hover {
    background: #218838;
}
EOF

# Update main navigation
sed -i 's|<a href="portfolio.html">Portfolio</a>|<a href="projects.html">Projects</a>|' index.html

# Commit changes
git add .
git commit -m "Add projects section with responsive grid layout

- Create projects.html with project showcase
- Add responsive CSS grid for project cards
- Include hover effects and tech stack tags
- Update navigation in index.html"

Step 2: Push Branch to GitHub

bash
# Push feature branch
git push -u origin feature/add-projects-section

Output:

Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 2.1 KiB | 2.1 MiB/s, done.
Total 5 (delta 2), reused 0 (delta 0)
remote:
remote: Create a pull request for 'feature/add-projects-section' on GitHub by visiting:
remote:      https://github.com/yourusername/portfolio-website/pull/new/feature/add-projects-section
remote:
To https://github.com/yourusername/portfolio-website.git
 * [new branch]      feature/add-projects-section -> feature/add-projects-section
Branch 'feature/add-projects-section' set up to track remote branch 'feature/add-projects-section' from 'origin'.

Step 3: Create Pull Request on GitHub

  1. Go to GitHub repository
  2. Click "Compare & pull request" (appears after pushing)
  3. Fill out PR template:
markdown
## Description

Adds a comprehensive projects section to showcase portfolio work with responsive design and interactive elements.

## Changes Made

- ✅ Created projects.html with project showcase
- ✅ Added responsive CSS grid layout
- ✅ Implemented hover effects for better UX
- ✅ Added tech stack tags for each project
- ✅ Updated main navigation

## Type of Change

- [x] New feature
- [ ] Bug fix
- [ ] Documentation update
- [ ] Performance improvement

## Testing

- [x] Tested responsive design on mobile/desktop
- [x] Verified all links work correctly
- [x] Checked cross-browser compatibility
- [x] Validated HTML and CSS

## Screenshots

[Add screenshots of the new projects section]

## Checklist

- [x] Code follows project style guidelines
- [x] Self-review completed
- [x] Comments added for complex logic
- [x] No console errors
- [x] Responsive design tested
  1. Select reviewers
  2. Add labels (feature, frontend, etc.)
  3. Create pull request

Code Review Process

As a Reviewer

1. Review Checklist

markdown
## Code Review Checklist

### Functionality

- [ ] Does the code do what it's supposed to do?
- [ ] Are there any edge cases not handled?
- [ ] Is error handling appropriate?

### Code Quality

- [ ] Is the code readable and well-structured?
- [ ] Are variable and function names descriptive?
- [ ] Is there unnecessary code duplication?
- [ ] Are comments helpful and up-to-date?

### Performance

- [ ] Are there any performance concerns?
- [ ] Are images optimized?
- [ ] Is CSS efficient?

### Security

- [ ] Are there any security vulnerabilities?
- [ ] Is user input properly validated?
- [ ] Are sensitive data properly handled?

### Testing

- [ ] Are there adequate tests?
- [ ] Do all tests pass?
- [ ] Is the feature manually tested?

### Documentation

- [ ] Is documentation updated?
- [ ] Are breaking changes documented?

2. Providing Feedback

Good Review Comments:

markdown
# Suggestion for improvement

Consider using CSS custom properties for consistent spacing:

```css
:root {
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 2rem;
}

.projects-grid {
  gap: var(--spacing-lg);
}
```
PreviousResolving Merge ConflictsNextQuestion about implementation

Open source, free forever. Built by iammhador.

Contribute on GitHub