0
0
Gitdevops~30 mins

Stashing specific files in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Stashing Specific Files in Git
📖 Scenario: You are working on a project with multiple files changed. You want to temporarily save changes from only some files without committing them. This helps you switch tasks without losing work.
🎯 Goal: Learn how to stash changes from specific files using Git commands.
📋 What You'll Learn
Create a Git repository with three files: index.html, style.css, and script.js.
Modify all three files.
Stash changes only from style.css and script.js.
Verify the stash contains only those files.
Show the remaining unstashed changes.
💡 Why This Matters
🌍 Real World
Developers often need to save work temporarily on some files to switch tasks without committing unfinished changes.
💼 Career
Knowing how to stash specific files helps manage work efficiently in real projects and is a common skill in software development roles.
Progress0 / 4 steps
1
Create a Git repository and add files
Initialize a Git repository with three files named index.html, style.css, and script.js. Add some initial content to each file and commit them.
Git
Need a hint?

Use git init to start the repo. Use echo to create files. Use git add and git commit to save.

2
Modify all three files
Modify the files index.html, style.css, and script.js by adding one new line of text to each.
Git
Need a hint?

Use echo 'text' >> filename to add a line to each file.

3
Stash changes only from style.css and script.js
Use the Git stash command to stash changes only from the files style.css and script.js. Do not stash changes from index.html.
Git
Need a hint?

Use git stash push followed by the file names to stash specific files.

4
Show the stash list and remaining unstashed changes
Run commands to show the list of stashes and then show the unstashed changes remaining in index.html.
Git
Need a hint?

Use git stash list to see stashes and git diff to see unstashed changes.