Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

I'd like to be able to stash just the changes from a single file:

git stash save -- just_my_file.txt

The above doesn't work though. Any alternatives?

1 Answer

0 votes
by (62.9k points)

I think stash -p is perhaps the choice you want, however simply in case you run into alternative even more tough things in the future, keep in mind that:

Stash is absolutely just a really straightforward alternative to the only slightly more complex branch sets. Stash is very useful for moving things around quickly, but you can accomplish more complex things with branches without that much more headache and work.

# git checkout -b tmpbranch

# git add the_file

# git commit -m "stashing the_file"

# git checkout master

go about and do what you want, and then later simply rebase and/or merge the tmpbranch. It really is not that a lot of extra work when you need to do more careful tracking than stash can permit.

Browse Categories