I'm adding a feature on master branch. After changing several files, I realize that I need to check the output without my changes.
The way I can think of is:
git reset --hard HEAD^
so that I get back to the original code.Is there a better way for this?
Can I save a snapshot of current changes and come back later when I am ready?
You can simply use git stash
, which will store away your change to the local working tree. Then do your things, and when you're done, git stash pop
to get things back. See the documentation about stashing.
This is exactly what stashing
is designed for.
Basically:
git stash save
to save your changes in a side location (i.e., the stash)git stash pop
to return your changes to the working directory.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With