Just wanted to understand if the git reset --hard origin/master
command affect my stash stack. I am yet to try this out but I do not want it to reset my stash as I have some changes I want to apply after my branch is reset.
To review, git reset is a powerful command that is used to undo local changes to the state of a Git repo. Git reset operates on "The Three Trees of Git". These trees are the Commit History ( HEAD ), the Staging Index, and the Working Directory. There are three command line options that correspond to the three trees.
Git stash vs.A reset creates a new commit point in the branch history; stash does not. A reset can jump back to any prior commit; a stash can only reset the files in the workspace to the point of the previous commit. A hard reset will discard all changes; a stash saves a snapshot of all locally modified files.
They all rewrite Git history, and they all move the HEAD back, but they deal with the changes differently: git reset --soft , which will keep your files, and stage all changes back automatically. git reset --hard , which will completely destroy any changes and remove them from the local directory.
You can reapply the stashed content by running git stash apply . You can also apply a specific stash (if you have stashed more than once) by running git stash apply stash@{1} (the '1' denotes the second before the last stash).
No, git reset --hard origin/master
does not affect your stashes in any way.
The hard reset command you showed above would move the HEAD pointer of whatever the current branch might be to origin/master
, but it would not affect the stash commits, which are stored in .git/refs/stash
.
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