Hello there, students in this class and we are going to lunch with you get Stasch command.
I'm going to tell you when you might need to use it.
You'll understand how to reapply changes from your stash on real examples.
I will show you how to manage multiple stashes and even how to create a branch from your stash.
And also, we are going to run different commands that will allow you to clean your stash and to perform
as operations with it.
Let's start first of all, let's understand potential problems at stash command may help us to resolve.
Imagine that you are sitting at your computer and work on some task and all of a sudden you receive
a call from your manager.
Your manager screams that you urgently need to fix some other thing or you have to start work on the
other task immediately.
But it didn't finish your current task.
Your manager told you that you have to give up everything and start work on the new task.
The state of a file system doesn't allow you to create a committee right now, probably because you
even can't build your project successfully or you are just in the middle of something important to finish.
And it looks like that you have to put all your changes aside to get back to them later.
Hope that you understood the problem and real life case that might happen with you almost on a daily
basis.
But how to address this issue with the help of the Get Eustache Command will help us with this station.
Take the state of a working directory that is humidified direct files, stage changes and saves it on
a stack of unfinished changes that you can apply at any time, even on different branch.
What a staircase.
I will explain a bit later.
Nonwork.
I believe that the best way to understand how Eustache Command works is to show it to you in it.
But I am a master branch right now and my work in tree is clean.
Let's imagine I'm in the process of implementation of some important task.
I create a new branch and get to reach resorption c a three zero six important task.
OK, and being on this branch in SASE folder, I modified home HTML file to not switch the windows between
different code editors.
Let me do small changes right here in the terminal using nano text editor nano web content slash home
dot html.
I added some important changes here.
Be some important line tag is closed.
After I did all my changes, I saved a file and now I received a message from my manager who is in panic
and asks me to start work on the super important task.
I don't need changes from home HTML file that we have just created.
Deunan another task implementation.
Let me check the status of my branch, get status and you can see I have one file modified and currently
it is in the state one creating snapshot with it doesn't make a lot of sense.
So I will put a temporary in my stash.
How simply by executing the next command.
Eustache Great.
Now our changes are in Stasch.
Let's check status one more time and you can see that right now it is nothing to commit.
But now I can be sure that my changes won't disappear.
I'm returning to the Master Branch to create the new branch uSwitch Dash.
Here I create a new branch, uSwitch, which resorption CGA three 07.
Super important task.
OK, and now I can continue work on my new important task.
My changes that are currently in Stasch are not present on this branch.
Let me show you this.
None of Condon's home, not HTML.
And we can find our important line here cuz now let's imagine that you realize that you need those changes
here and you need them back.
How get your changes back from Stasch.
You need to apply changes from your stash to do this.
Let's use the next command.
Eustache apply.
And instantly you see the status of the branch and indications and home e-mail file is modified, let
me open it to double check.
Yes, I see my important line here.
Awesome.
Now, important information about Stasch, this command, great stack of changes.
They understand how a stack of changes may look like.
Let me show you quickly.
In computer science, tech is an abstract data type that serves as a collection of elements, it works
according to leave for principle.
One more fancy word what does leave or stand for?
Leifur is an acronym from Last In, First Out.
This is a method of storing data in data structures, according to which the last element get into the
container, leaves the containers the first.
And on the screen you can see visualization of Steck.
Imagine that each element here is a separate batch of changes.
When you use Stasch command, your changes are on the bottom of this container.
When you use against apply command, the changes from top of the stack apply to your branch.
And if you use git stash command multiple times, the new changes will be on top.
Does it make sense?
Now imagine that you used Stasch command multiple times and you have a lot of changes in your Stasch
stack, how to view all changes that you have in your stack of changes.
Let me show you the list.
All the changes that you have in your stack.
Use the next command git stash list.
And specially for this lesson, I prepared a few items to have multiple elements here.
You can see that our last stash has index zero and it is on the top of our stack.
That means you can apply it on different branches, but probably you might be wondering how to apply.
Are the changes from the stack for the sake of the demo?
Let me apply changes from this stack.
Was the indexed One Eustache apply and after that I will use the name of the stash that is specified
here, stash add and one in curly brackets.
Before I press and I want to warn you that you're going to see error message hypocenter.
And as I promised, here is the error.
Don't worry, everything is under control.
I did this on purpose to show you this error message that you may see some time get.
Sometimes we'll show you this message to warn you that your changes might be overwritten after some
specific operation.
And this is one more case to Eustache as a temporary storage for your changes.
I already have these changes in my stash.
So let me just come in, then get dash a dash and commit.
Sorry about this message, just don't want to spend time on the details that we already discussed.
Hope you understand that such a meaningful message is not the best practice.
And I use it only for the sake of the drama to not lose the focus from the Stasch.
Come on now.
When I created the snapshot, let me try to apply one more time.
Are the changes from the Stasch and you see that some changes were applied here.
Namely, Log-in says, as file was removed and changes in home each time on file were also applied.
There is even a conflict in this file since it was modified in different versions.
You just have to open this file and to resolve conflicts for the sake of the demo.
Let me reset the state of the current branch to its original state, yet reset resorption heart to the
head pointer.
Let's talk about another problem.
Do you remember what is in my stash list?
Let me show it one more time yet stash lists.
How do you think will I remember that that changes and how much time I'll file in the stash tomorrow
or in a month.
That's why it usually does a good practice to give a name to each stash.
Let me do some changes in the repository.
For example, let me remove login scissors file ram style slash logging that says there is a standard
command in Linux terminals to remove files.
Let me stash my current changes with a specific message you'd stash safe logins, he says is removed
and lets presenta.
Now, when I will see the stash in the future in my specialist, I will instantly understand what changes
it contains existentialists.
And here I can see my last stash and it is on the top of the stack.
Great.
OK, now let me explain you one more thing, probably you noticed that I applied different stashes,
but they're still in my stack how to apply stash and remove it from the stack for doing this.
You have to use Bob Camonte instead of apply like this.
Eustache Pop, we see that I applied my last stash and login success is removed.
Let me check my specialist now.
And now you can see that it has disappeared from here.
Let's move on.
One more thing that we didn't discuss yet is that you can stash only changes that are in the staging
area or changes that were done in files that are tracked by it.
Imagine that we created a file and after that we were interrupted.
We have to stash it.
Let me quickly create a file here, touch some important file dot java right now.
This file isn't tracked by yet.
Let me show you this.
It's status.
And in case I would try to suggest changes on the removal of Logan's SS will be stored.
Let me prove you this, Eustache.
And now let's check your status one more time and see that my new file is still in Ontrack State and
is not in the Stasch, how to add it to the stash?
We have to use a special option for that.
Let me show you need Stasch with option U.
U stands for untracked files.
Instead of you, you can use a option.
A stands for all besides untracked files.
It would also stash files that are ignored according to our Getting Your File.
But I doubt that you would ever want it to include ignored files to your stash.
That's why.
Let's use you option here, Hypocenter.
Let me check your status now, your status.
Awesome.
Finally, it looks like our new file was stashed, and now imagine that you want to create a branch
from your stash.
Imagine that when you finished work on the super important task, you already removed all old branches
and you have to create a new one.
How to create a new branch from Stash use the next command, Eustache Branch, a three zero seven new.
You can specify here any Stasha you would like without specifying Stasha.
The first stash from the stack will be used and you see that I have new untracked file on my new branch
that also moved me to the new branch.
You can see it here in parentheses and what to do in case you don't want to apply your stash, but you
just want to remove it, use the next command, get stash, drop.
You can specify any stash.
I here, for example, stash at zero.
Now let's check stash list, new stash list.
And you see that our first stash in stack was removed by us.
In case you want to clear all stack of stashes, use the next command, get Stasch clear.
And in case we would check our specialists, now we are going to see nothing and here is empty list,
nothing is here.
Great, it looks like that is all what I plan to share with you in this lesson.
Let's recap what we have learned today.
So today we learned what the stashes now we know how to use stash.
Come on, on real examples.
We learned how to manage multiple stashes.
We learned how to stash direct files and how to clear your stash if needed.
We also learned what is the difference between stash supply and stash pop.
That's all for now.
Thanks a lot for your attention.
See you in the next lesson.