Jump to content

How to Git stash Pop Specific Stash


Recommended Posts

Stash is one of the major functions of the Git platform that enables users to save changes. It is referred to as temporary storage. However, sometimes developers in Git are required to switch Git repositories or branches to review other branch functionalities or to fix bugs. In this type of scenario, the stash is utilized to temporarily save the current changes of a working repository in the Stash index. After saving changes, Git users can easily switch to another branch.

This blog will elaborate on how to Git stash pop a specific Git.

How to Git stash Pop Specific Stash?

To pop the specific Git stash, first, open the repository of Git. Next, view the list of stashes and note the stash reference. After that, utilize the Git “stash” along with stash reference to pop the specific stash.

For this purpose, the below provided instructions are effective enough.

Step 1: Launch Git Terminal

From the Windows “Startup” menu, open the Git command line terminal:

Screenshot-2022-12-13-145434.png
Step 2: Move to Repository

Utilize the “cd <repo-path>” command to move to the repository:

$ cd "C:Git"

 
Screenshot-2022-12-13-145606.png
Step 3: Create New File

Next, create a text file by executing the “touch” command:

$ touch File.txt

 
Screenshot-2022-12-13-145716.png
Step 4: Track the New File

Add the text file to the repository tracking index with the help of the given command:

$ git add File.txt

 
Screenshot-2022-12-13-145816.png
Check the repository state and confirm if the text file is added to the tracking index or not:

$ git status

 
Screenshot-2022-12-13-145913.png
Step 5: Create New Stash

To create a new stash before moving to another branch, take a look at the provided command:

$ git stash

 
Screenshot-2022-12-13-150048.png
Next, view the stash list and note the reference of the stash you want to pop:

$ git stash list

 
For instance, let’s pop the Git stash with the reference “2”:

Screenshot-2022-12-13-150214.png
Step 6: Apply Specific Stash

Now, pop out or apply the specific stash using the “git stash apply <stash@{reference}>” command:

$ git stash apply stash@{2}

 
Here, you can see we have successfully popped the specific stash in Git:

Screenshot-2022-12-13-150328.png
Here we go! We have elaborated on the method to pop the specific stash using the Git “stash” command.

Conclusion

To pop the specific stash using Git “stash”, first, navigate to the repository of Git. View the list of available stashes and note the reference number of stashes you want to pop. After that, utilize the “git stash apply <stash@{reference}>” command to pop the specific stash. This post has demonstrated how the Git stash pops the specific stash.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...