1

I find my commit where I deleted 10 files. After that, I committed a couple of times. NOw I only want to get these 10 files back on my branch

git log --diff-filter=D --summary 

shows

    Deleted 10 TIP files

 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/INT/api-service TIP [Common]/INT_COMMON.json
 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/INT/api-service TIP [Xamarin]/INT_XAMARIN_ANDROID.json
 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/INT/api-service TIP [Xamarin]/INT_XAMARIN_IOS.json
 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/INT/api-service TIP [iOS]/INT_IOS_BitBucket.json
 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/INT/api-service TIP [iOS]/INT_IOS_GitHub.json
 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/PROD/api-service TIP [Common]/PROD_COMMON.json
 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/PROD/api-service TIP [Xamarin]/PROD_XAMARIN_ANDROID.json
 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/PROD/api-service TIP [Xamarin]/PROD_XAMARIN_IOS.json
 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/PROD/api-service TIP [iOS]/INT_IOS_BitBucket.json
 delete mode 100644 test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/PROD/api-service TIP [iOS]/INT_IOS_GitHub.json

I tried

git checkout 525afffc8641671f9fe2c33b68dc211ed20d0ec8 -- "test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/INT/api-service TIP [Common]/INT_COMMON.json"

but got error with path

error: pathspec 'test-runner/src/v2/Avalanche.TestRunner.BuildsScenarios/Configuration/INT/api-service' did not match any file(s) known to git

If I go for

    git checkout 525afffc8641671f9fe2c33b68dc211ed20d0ec8
HEAD is now at 525afffc864 Deleted 10 TIP files

What next?

How to fix this?

MikiBelavista
  • 2,470
  • 10
  • 48
  • 70
  • 1
    Does this answer your question? [How can I reset or revert a file to a specific revision?](https://stackoverflow.com/questions/215718/how-can-i-reset-or-revert-a-file-to-a-specific-revision) – 0x5C91 Jan 12 '22 at 08:43
  • 2
    As you can see error clearly cuts the path to file on encountering space character, you need to somehow indicate that spaces are part of the name. Try putting the "test-runner [...] .json" inside quotation marks. – matszwecja Jan 12 '22 at 08:43
  • @matszwecja I got the same with quotation marks. – MikiBelavista Jan 12 '22 at 08:48
  • @MikiBelavista That's impossible; the error info can by no means be the same with quotation marks. – lzhh Jan 12 '22 at 08:55

1 Answers1

3

It looks like 525afffc86... is the commit where you deleted the files.

If such is the case, the files do not exist in that commit, which is why you get the did not match any file(s) known to git error, they exist in the parent commit :

# <commit-ish>^ points to the parent of target commit :
git checkout 525afffc^ -- "test-runner/src/v2/ ... /INT_COMMON.json"
LeGEC
  • 46,477
  • 5
  • 57
  • 104