Performing any reset
for the previous commit will remove your subsequent commits from your branch so that they are no longer part of it. The end is the elements that you see when you do git log
.
This does not mean that those commits are destroyed immediately, but since you do not intend to get rid of them, you probably want to create another branch and use it to view your previous commit so that your original branch remains unchanged. (Keywords for creating a new branch: git branch <name>
or git checkout -b <name>
. **)
Hard and soft reset has more in common with what happens to files in the working tree, and, more importantly, unmanaged changes. In essence, the only things that were destroyed when specifying --hard
were your unstated changes. As long as you leave the branch in your last commit (or you remember the commit identifier), you can always restore files by going to this branch or commit. (i.e. git checkout
)
** You can look around without creating an additional branch, and Daniel Pittman's answer describes this.
source share