I have a Jupyter Notebook which I often use to try out new functionality in my code. The Jupyter Notebook is also tracked by Git. After adding the important changes (to different file(s), not the changes to the Notebook) to the index and committing them, I find this Notebook file ruining my clean git status
. In order to restore its previous state, I find myself doing
git stash push convenient_notebook.ipynb
git stash drop
frequently -- always in fear I did something wrong and git stash drop
a change I still need.
Is there a single command which trashes all unstaged changes, ideally with the option to specify a file?
This answer to a similar question suggests git checkout -- .
, but I don't understand why this works and whether it is appropriate.
This answer to the same question suggests roughly what I do right now, i.e. the two successive commands I'd like to get rid of.