Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (29.3k points)

How can I stash a specific file leaving the others currently modified out of the stash I am about to save?

For example, if git status gives me this:

younker % gst      

# On branch master

# Your branch is ahead of 'origin/master' by 1 commit.

#

# Changes not staged for commit:

#   (use "git add <file>..." to update what will be committed)

#   (use "git checkout -- <file>..." to discard changes in working directory)

#

#   modified:   app/controllers/cart_controller.php

#   modified:   app/views/cart/welcome.thtml

#

no changes added to commit (use "git add" and/or "git commit -a")

and I only want to stash app/views/cart/welcome.thtml, how would I do that? Something like (but of course this does not work):

git stash save welcome_cart app/views/cart/welcome.thtml

1 Answer

0 votes
by (50.2k points)

Since git is updated to 2.1.3, we have a command to save a specific path to stash

Syntax: 

git stash push <path>

For your query use 

git stash push -m welcome_cart app/views/cart/welcome.html

Related questions

Browse Categories

...