Q:

How can I restore file in master branch

I was coding on branch called feature/restful-api, and I want to checkout the files in master branch, so I did
git checkout master and changed to master branch.
When I wanted to change back, git told me that
error: The following untracked working tree files would be overwritten by checkout:
        gradle/wrapper/gradle-wrapper.jar
        gradle/wrapper/gradle-wrapper.properties
        gradlew
        gradlew.bat
Please move or remove them before you switch branches.
Aborting

So I deleted these files and changed back to feature/restful-api branch.
Now I found that all the configurations has gone. How can I restore these file back? 

A:

It seems you've deleted the files without Git ever knowing about them. In that case Git can't help you get them back. I'm assuming they're not in Trash/Recycle Bin either.
If you're using IntelliJ IDEA, try the Local History feature. Open the project in IDEA, right-click the root of the project and select Local History > Show History...
I've recovered a few files this way, can be a life saver.

