Test Stashless Repository
In the previous steps, we confirmed that our repository is clean and has no existing stashes. This is the ideal state to begin experimenting with git stash
.
To demonstrate how git stash
works, we first need to make some changes to our repository. Let's modify the message.txt
file we created in the previous lab.
Make sure you are in the ~/project/my-time-machine
directory. Open the message.txt
file using the nano
editor:
nano message.txt
Add a new line to the file, for example:
Hello, Future Me
This is a new line.
Save the file by pressing Ctrl + S
and exit nano
by pressing Ctrl + X
.
Now, let's check the status of our repository again:
git status
You should see output indicating that message.txt
has been modified:
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: message.txt
no changes added to commit (use "git add" and/or "git commit -a")
This output shows that we have made changes to message.txt
, but these changes are not yet staged for a commit. This is the perfect scenario to use git stash
. In the next step, we will use git stash
to save these changes temporarily.