DEV Community

ಮಿಥುನ್
ಮಿಥುನ್

Posted on

git stash usage for beginners

In the below branch tree, let's say you are working on Feature-branch-helper.

  • master
    • develop
      • Feature-branch
        • Feature-branch-helper

Now you completed working on Feature-branch-helper, before you merge with Feature-branch, you would want to take latest from Feature-branch. Without taking latest from Feature-branch you cannot merge. In this case we can use git stash.

Steps I follow to update current branch. Assuming you are in Feature-branch-helper.

First take backup of your changes

 git stash          
Enter fullscreen mode Exit fullscreen mode

Second take latest of Feature-branch

 git pull origin Feature-branch
Enter fullscreen mode Exit fullscreen mode

Resume your changes to your branch ,Feature-branch-helper

 git stash pop
Enter fullscreen mode Exit fullscreen mode

Top comments (0)