How to Save Your Changes Temporarily ?

How to Save Your Changes Temporarily ?

# What is stash ?


We all deal with different jobs during the day. Sometimes when you are in the middle of a job, it is necessary to start another job. Are we going to say goodbye to our codes that we started doing in such cases but we have not finished yet?

In this case, the stash structure is coming to our rescue. It maintains a list-like structure within the stash structure. we can discard our code changes we want to save here and save them for later use. Isn't it great?

# From the Git Manual (run git stash --help to see it on your own):


Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

You ensure that any changes that you have been working with git stash but have not yet committed are temporarily recorded by Git and that your active branch is brought to a clean state where there are no changes.

# Keywords


So how can we use it?

Let's think we have a bucket. We throw the changes we make into the bucket. What if we want to look at what's in the bucket?

git stash list

So how can we throw our changes to stash?

stash save "lets add changes"

# Pop or Apply ?


You have two options when you want to restore a change in Stash. Let's examine it?

# git stash pop


git stash pop

Stash restores the top of all changes and deletes those changes from the stash list.

# git stash apply


git stash apply

Stash restores the top of all changes and does not delete these changes from the stash list.


For now, our article ends here. However, we can continue in more detail later. 😎


Read More