Assignment 7 - Stashing Practice
For this assignment, you will practice using Git stash to handle workflow interruptions while building a simple website project.
Show/Hide Video
Instructions
Part 1: Set Up Your Project
Create a new project folder called
your-name-stashing-practice. For example,john-doe-stashing-practice.Initialize it as a Git repository:
git init
- Create a basic HTML file called
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Portfolio</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>Welcome to My Portfolio</h1>
</header>
<main>
<p>This is my personal website where I showcase my work.</p>
</main>
</body>
</html>
- Create a CSS file called
styles.css:
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f5f5f5;
}
header {
text-align: center;
margin-bottom: 30px;
}
h1 {
color: #333;
}
main {
max-width: 800px;
margin: 0 auto;
}
- Make your initial commit:
git add .
git commit -m "Initial portfolio setup"
- Push your project to GitHub (create a new repository called
your-name-stashing-practice)
Part 2: Feature Development with Interruptions
Scenario 1: Working on Navigation
- Start working on a navigation menu. Add this code inside the
<header>section (after the<h1>tag) in yourindex.html:
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
</ul>
</nav>
- Add some CSS styling for the navigation in your
styles.cssfile:
nav ul {
list-style: none;
padding: 0;
display: flex;
justify-content: center;
}
nav li {
margin: 0 15px;
}
- BEFORE committing this work, you realize you need to fix an urgent issue with the page title. Stash your navigation work:
git stash push -m "Working on navigation menu"
Fix the urgent issue - change the page title from "My Portfolio" to "My Awesome Portfolio" in the
<title>tag.Commit the title fix:
git add index.html
git commit -m "Fix: Update page title"
- Return to your navigation work:
git stash pop
- Complete the navigation by adding one more link in the HTML:
<li><a href="#contact">Contact</a></li>
- Commit your completed navigation feature:
git add .
git commit -m "Add navigation menu"
Scenario 2: Working on About Section
- Start working on an About section. Add this after the existing
<p>tag in yourindex.html:
<section id="about">
<h2>About Me</h2>
<p>I'm a student learning web development and Git!</p>
</section>
- Add CSS styling for the About section in
styles.css:
section {
margin: 30px 0;
padding: 20px;
background-color: white;
border-radius: 5px;
}
h2 {
color: #555;
}
- BEFORE committing, you need to pull the latest changes from your remote repository. Stash your About section work:
git stash push -m "Adding About section"
- Pull any updates from your remote repository:
git pull
- Restore your About section work:
git stash pop
- Complete and commit your About section:
git add .
git commit -m "Add About section"
Scenario 3: Working on Contact Information
- Start adding contact information. Add this section after your About section:
<section id="contact">
<h2>Contact Me</h2>
<p>Email: your.email@example.com</p>
</section>
- Realize you're working on the wrong feature! You should be working on a footer instead. Stash your contact work:
git stash push -m "Contact info work - wrong priority"
- Work on the footer instead. Add this before the closing
</body>tag:
<footer>
<p>© 2025 My Portfolio. All rights reserved.</p>
</footer>
- Add footer CSS to your
styles.css:
footer {
text-align: center;
margin-top: 40px;
padding: 20px;
background-color: #333;
color: white;
}
- Commit your footer:
git add .
git commit -m "Add footer"
- Now go back to your contact work:
git stash pop
- Finish and commit your contact section:
git add .
git commit -m "Add contact section"
- Push all your changes to GitHub:
git push
Part 3: Clean Up
- Check if you have any remaining stashes:
git stash list
- If you have any old stashes, clean them up:
git stash clear
Submission
Once you have completed all the tasks, submit the following in Blackboard:
The URL of your GitHub repository
Paste the output of the following command:
git log --oneline
Answer these questions:
How many times did you use
git stash pushin this assignment?Describe a real-world scenario where you might need to stash your work.
Why is it helpful to add messages to your stashes (using the
-mflag)?
Note
Your final website should have a header with navigation, a main content area with About and Contact sections, and a footer. Make sure to test your HTML file in a browser to see how it looks!