Project Task 3: Push and Pull Workflow
Practice a complete push/pull workflow with your portfolio project.
Objective
Master the synchronization between local and remote repositories.
Part 1: Local Changes → Push
Step 1: Make Local Improvements
bash
1cd portfolio-project
2
3# Update the main heading
4# Edit index.html to improve the designAdd a new section to index.html:
html
1<section id="skills">
2 <h2>My Skills</h2>
3 <ul>
4 <li>HTML5 & CSS3</li>
5 <li>JavaScript</li>
6 <li>Git & GitHub</li>
7 <li>Responsive Design</li>
8 </ul>
9</section>Add styles to css/style.css:
css
1#skills {
2 padding: 2rem;
3 background: #f9f9f9;
4}
5
6#skills ul {
7 list-style: none;
8 display: flex;
9 flex-wrap: wrap;
10 gap: 1rem;
11}
12
13#skills li {
14 background: #333;
15 color: white;
16 padding: 0.5rem 1rem;
17 border-radius: 4px;
18}Step 2: Commit and Push
bash
1# Stage changes
2git add index.html css/style.css
3
4# Commit
5git commit -m "Add skills section with styling"
6
7# Push
8git push origin mainStep 3: Verify on GitHub
- Go to your repository on GitHub
- Verify the new commit appears
- Check the files are updated
Part 2: Remote Changes → Pull
Step 4: Make Changes on GitHub
- On GitHub, click on
README.md - Edit to add more content:
markdown
1# My Portfolio Project
2
3A personal portfolio website showcasing my skills and projects.
4
5## Features
6- Responsive design
7- Clean code structure
8- Skills showcase
9- Contact information
10
11## Technologies
12- HTML5
13- CSS3
14- JavaScript
15- Git
16
17## Getting Started
181. Clone this repository
192. Open index.html in your browser
20
21## Author
22Your Name
23
24## License
25MIT- Commit with message: "Update README with detailed documentation"
Step 5: Pull to Local
bash
1# Fetch first to see what's new
2git fetch origin
3
4# Check what's new
5git log HEAD..origin/main --oneline
6
7# Pull the changes
8git pull origin main
9
10# Verify
11cat README.mdPart 3: Simulate Team Collaboration
Step 6: Create Feature Branch
bash
1# Create and switch to feature branch
2git checkout -b feature/footer
3
4# Add footer to index.html
5cat >> index.html << 'EOF'
6 <footer>
7 <p>© 2024 My Portfolio. All rights reserved.</p>
8 <nav>
9 <a href="https://github.com/username">GitHub</a>
10 <a href="https://linkedin.com/in/username">LinkedIn</a>
11 </nav>
12 </footer>
13EOF
14
15# Add footer styles
16cat >> css/style.css << 'EOF'
17
18footer {
19 background: #333;
20 color: white;
21 padding: 2rem;
22 text-align: center;
23 margin-top: 2rem;
24}
25
26footer a {
27 color: #4CAF50;
28 margin: 0 1rem;
29}
30EOF
31
32# Commit
33git add .
34git commit -m "Add footer with social links"
35
36# Push feature branch
37git push -u origin feature/footerStep 7: While on Feature Branch, Main Gets Updated
Simulate this by editing on GitHub:
- Go to repository on GitHub
- Switch to
mainbranch - Edit
js/main.json GitHub:
javascript
1// Main JavaScript file
2console.log('Portfolio loaded!');
3
4// Smooth scrolling for navigation
5document.querySelectorAll('a[href^="#"]').forEach(anchor => {
6 anchor.addEventListener('click', function (e) {
7 e.preventDefault();
8 document.querySelector(this.getAttribute('href')).scrollIntoView({
9 behavior: 'smooth'
10 });
11 });
12});- Commit with message: "Add smooth scrolling feature"
Step 8: Update Feature Branch with Main
bash
1# Fetch latest
2git fetch origin
3
4# Update your local main
5git checkout main
6git pull origin main
7
8# Go back to feature branch
9git checkout feature/footer
10
11# Merge main into feature
12git merge main
13
14# Or rebase (cleaner history)
15# git rebase main
16
17# Push updated feature branch
18git push origin feature/footerStep 9: Merge Feature to Main
bash
1# Switch to main
2git checkout main
3
4# Merge feature
5git merge feature/footer
6
7# Push main
8git push origin main
9
10# Delete feature branch
11git branch -d feature/footer
12git push origin --delete feature/footerVerification Checklist
- Skills section visible on GitHub
- README.md updated locally
- Footer merged to main
- Smooth scrolling in main.js
- Feature branch deleted
Troubleshooting
Push Rejected
bash
1# Pull first
2git pull origin main
3
4# Then push
5git push origin mainMerge Conflicts
bash
1# After git pull or git merge
2# Edit conflicting files
3# Remove conflict markers
4
5git add .
6git commit -m "Resolve merge conflicts"Lost Track of Changes
bash
1# See all recent activity
2git log --oneline --all --graph -10Summary
In Task 3, you practiced:
- ✅ Pushing local changes
- ✅ Pulling remote changes
- ✅ Feature branch workflow
- ✅ Keeping branches in sync
- ✅ Merging and cleanup
Next: Learn about GitHub Issues and Pull Requests!
