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

20 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

  3. I appreciate, cause I found exactly what I used to be looking for.

    You have ended my 4 day long hunt! God Bless
    you man. Have a nice day. Bye

  4. Good day! I could have sworn I’ve been to this website before but after
    reading through some of the post I realized it’s new to me.
    Nonetheless, I’m definitely glad I found it and
    I’ll be bookmarking and checking back frequently!

  5. It is not my first time to go to see this site, i am browsing this website dailly and obtain nice facts from here every day.

  6. We are a group of volunteers and starting a new scheme in our community.
    Your web site offered us with valuable info to work on. You have done a formidable job and our
    entire community will be grateful to you.

  7. Wow, this piece of writing is fastidious, my younger sister is analyzing these things, therefore I am
    going to tell her.

  8. Τhis is rеally interesting, You are a very skilled blogger.
    I have joined your feed and look forwаrd to seekіng more
    of your fantastic post. Alsо, I’ve shaгeԁ your website in my social networks!

  9. Hi there it’s me, I am also visiting this site on a regular basis, this web page is actually pleasant and the viewers are actually sharing fastidious thoughts.

  10. I feel that is among the such a lot important information for me.
    And i’m satisfied studying your article. However should statement on few
    basic things, The web site taste is great, the articles is truly nice :
    D. Good job, cheers

Leave a Reply

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

Back to Top