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
You can read more at https://docs.github.com/en.
Also, Check:
- 5 Most Effective Ways To Optimize PHP Code
- Debugging in PHP: A Comprehensive Guide with Examples
- How to Install the latest version of Laravel?
- 3 popular ways to make HTTP requests in JavaScript