How To

How to Use the Git Stash Command with example

Git is a useful part for developers and in development. And Git Stash is one of the best features of GIT. By...

Written by Bikash · 1 min read >

Git is a useful part for developers and in development. And Git Stash is one of the best features of GIT.

By using the Git Stash command, user can save their code changes without committing them. Here we discuss all the Git Stash commands with the help of examples.

Points we will discuss in this article,

  • Why Use Git Stash?
  • How to Use the Git Stash Command?

Why Use Git Stash?

There are many situations where we have to use the Git stash command. For example, if you want to switch to another branch from your working branch and there are many changed or modified files and you can switch to another branch by stashing the files using the stash command, and also no need to commit.

The git stash command saves the modified files without committing them.

How to Use the Git Stash Command?

To use the Git Stash Command, here are some steps,

Step 1: Do some changes inside your code and save it. For example, create any function on your codebase and save it.

Step 2: Now you can see the changed files on git status. Now you can run the git stash command and it will save the current file changes on a temporary stash.

To run the git stash command you need to navigate the root directory of your git repository.

Step 3: Now, you can also check the stash list by running the below command,

git stash list

This command will show you, your stashed files.

Step4: After checking the stash files, if you want to restore your stash files you can restore by running the below command,

git stash pop

Now, this command will restore all the stashed files and you can check it by using the git status command.

Now, if you want to commit your changes you can do it.

Complete Process Video of Git stash Command

Complete Process Video of Git stash Command

You can read more at https://docs.github.com/en.

Also, Check:

Was this article helpful?
YesNo
Written by Bikash
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP. Profile

Leave a Reply

Your email address will not be published. Required fields are marked *