Today I Learned Notes to self about software development

    Using a path with `git stash`

    Oftentimes when I’m experimenting in a project I make a bunch of changes and then want to keep some of them (without committing) but undo the rest. I would try to stage the changes that I didn’t want and them stash them like this:

    git add path/to/undesired/changes
    git stash
    

    But this would stash everything, including the changes I wanted to keep.

    I tried being more specific with stash bu providing a path, but no dice.

    $ git stash path/to/undesired/changes
    fatal: unknown subcommand: path/to/undesired/changes
    

    I think in an older version of Git this used to work, but I found the updated command today: git stash push _path_ --keep-index

    $ git stash push path/to/undesired/changes --keep-index
    Saved working directory and index state WIP on _branch_name_: 32dbc82 .
    

    Thanks to this post.

    #git