Git Stash

To understand the use case of git stash let’s assume that you are working on a file for task T1 and made some changes. Meanwhile you have another task T2 which is to be done on the priority basis. And you don’t want to commit the changes made. In this scenario one option is to revert the changes you made for T1 so that file is not in the modified state. Then complete and commit the task T2 and rework on the task T1. This is not a good approach. To overcome this type of situation, git have a feature to save the modified files.

In short, If you don’t want to commit the changes you made and want to continue modifying the files later, you can save the modified files by using Stash feature. Later, when you want to continue modifying the files, you can apply saved stash or delete them if they are no longer required.

Save Stash

git stash save "stash name"

Check git status to ensure whether there is no file in modified state

git status

Check Stash List

git stash list

Apply a stash

git stash apply stash@{0}

Drop a stash if no longer required

git stash drop stash@{0}

pop last saved stash, this will apply last saved stash and delete the stash

git stash pop

11 Responses

  1. Hi there! Someone in my Myspace group shared this website with us so I came
    to take a look. I’m definitely enjoying the information. I’m book-marking and will be tweeting
    this to my followers! Terrific blog and brilliant design and style.

  2. Way cool! Some extremely valid points! I appreciate you writing
    this post and also the rest of the website is also really

Leave a Reply

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

Back to Top