Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»GIT»How to Git Stash Changes

    How to Git Stash Changes

    RahulBy RahulOctober 27, 20213 Mins ReadUpdated:October 29, 2021

    Ever had a need to temporarily store changes that you made to your code? Without committing it? For example, you were in the middle of branch editing and someone asked you to collaborate on a different one? If you didn’t, you most likely will somewhere down the road in your developer career. At that point, it will be extremely useful to know how to use git stash. With the help of that command, you can temporarily store your current work to jump onto something else. Read on and find out how to Git stash changes.

    How to Use Git Stash Command to Temporarily Save Your Changes

    Okay, so picture this scenario. You are currently working on a piece of code that should bring a new feature to the application. All of a sudden, you urgently have to assist one of your co-workers with a bug that they found in a completely different branch. The first thing that you would want to do is to check which files you recently modified in the branch on which you are currently working. You can do that with a simple command.

    git status 
    

    This command will show you modified files. Below, you can find an example of the output.

    Output:
    modified: app_layer.php modified: readme.txt modified: functions.php

    Of course that you don’t want to lose your work on these files, but on the other hand you can’t just commit them. And that is where git stash shines!

    The command itself is extremely easy and straightforward. An example is below.

    git stash 
    

    The output will look similar to the one below.

    Output:
    Saved working directory and index state WIP on master: 3tjaq12w Implement the new login box HEAD is now at 3tjaq12w Implement the new login box

    And that’s it! All your work on the current branch is saved in some sort of clipboard. Feel free to start working on whatever popped up in the meantime.

    Speaking of pop, here’s how you can return to the place where you left off once you are ready to continue. Simply type this into your terminal.

    git stash pop 
    

    After the command above, you will be returned to your last saved state.

    Conclusion

    You’ll agree with us when we say that this is a very simple Git command to learn and it is of real value to having knowledge of it. We certainly hope that you’ll find a good use for what you learned today. Remember, developing is a never-ending course when it comes to learning.

    git stash
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleTee Command in Linux with Examples
    Next Article How to Install and Configure Fail2ban on Debian 11

    Related Posts

    How To Add a Git Remote Repository

    3 Mins Read

    How to Git Reset to Head

    Updated:November 3, 20213 Mins Read

    How to Delete a File on Git

    3 Mins Read

    How to delete Git tags

    Updated:October 25, 20211 Min Read

    How to Create Git tags

    Updated:October 25, 20212 Mins Read

    How to Clone a Git Repository Into a Specific Folder

    Updated:October 14, 20212 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.