0

So my last commit completes the task. Now for performance benchMarking I added some logs and completed my performanceBench marking. I stashed the changes saved it in list.

$ git stash save peformanceBenchMarking

Today again I wanted to do performance BenchMarking, so I applied the stash saved.

$ git stash apply stash@{x}

Now how do I undo the change introduced by applying this stash? I would still want this stash later. I know it will be very simple thing, right now I am not able to think through it. Any help will be appreciated, Thank you.

Amitkumar Karnik
  • 912
  • 13
  • 23

3 Answers3

2

The stash apply command does not adds any commits to your branch, it's simply applies the changes (see the output of git status), thus you can

# Revert every change, so `git status`is (probaly) empty
$ git reset --hard
bimlas
  • 2,359
  • 1
  • 21
  • 29
  • thanks @bimlas, but git checkout {file/path} worked for me. – Amitkumar Karnik May 31 '18 at 06:16
  • Git `reset --hard` is the same, but it unstaging changes before checking out, so you will get the latest commit back: [Resets the index and working tree. Any changes to tracked files in the working tree since are discarded.](https://git-scm.com/docs/git-reset) The `` is the `HEAD` by default. – bimlas May 31 '18 at 06:48
1

There is another way that is not via Git command:

If use in "JetBrains" IDE (IntelliJ, PyCharm etc.),

Click right click on the main parent folder of the project and choose "Local History" and then "Show History":

enter image description here

Now can see on the new window on the right side all the files that have always been in the project according to the times on the left, and of course, make them revert or see differences.

It sometimes literally saves from problems

Gavriel Cohen
  • 4,355
  • 34
  • 39
0

You can do the following if you have other changes aside from the changes applied from the stash:

git stash show stash@{x} -p | git apply --reverse
Lunyx
  • 3,164
  • 6
  • 30
  • 46