My co-worker added some .ps1 files some time ago (several commits since, he might have modified only one of them again later etc. - so we can't assume it was all done in one commit). Let's say they were added in commit1 and later one of the files was modified in commit5.
I then accidentally committed some local changes (specific to my environment) to those .ps1 files, in addition to other changes I really wanted to commit. I had simply staged all changes and forgot to exclude my changes to the .ps1 files (which I want to keep locally, but not commit). We can call this commit14.
I then made another commit (to other files, commit15) and pushed my changes.
Basically it looks like this:
commit15 me Foo.cs, Bar.cs
commit14 me Foo.cs, Bazz.cs, [File1.ps1, File2.ps1, File3.ps1]
commit13 co-worker SomeCode.cs
...
commit5 co-worker File2.ps1
...
commit1 co-worker File1.ps1, File2.ps1, File3.ps1 (added)
I have since tried to revert these three .ps1 files (marked in square brackets above) by discarding any local changes in Bitkraken and then cd'ing into the directory containing the files and running:
$ git checkout commit14~1 -f -- File1.ps1 File2.ps1 File3.ps1
There was no output, but the files were then automatically listed as staged in Bitkraken. That got my hopes up - but then I realized the file contents were identical (including the changes I wanted to revert).
I have also tried like this:
$ git reset commit14~1 -- File1.ps1 File2.ps1 File3.ps1
The output was as follow:
Unstaged changes after reset:
M My/Path/File1.ps1
M My/path/File2.ps1
M My/Path/File3.ps1
Again the result was the same, the file contents were not changed. I have even tried specifying "commit13" explicitly instead of "commit14~1", but that didn't work either.
What am I doing wrong?
All of this happened on a branch called "dev", in case that matters.
And I'm not sure about the actual history of the .ps1 files, but I would strongly prefer if I didn't have to find out the last commit for each of them. This could easily have been more than 3 files. Surely there must be a way to say "Change these files back to the way they were before I accidentally committed them, no matter when they were last updated".
Thanks.