+1 vote
1 view
in Devops and Agile by (25.5k 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 (42.7k 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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...