I went through the same problem. You should use the Windows Device Recovery tool. You can download the tool from Microsoft here.
Note : You need an active internet connection on your PC.
- Download and install the Windows device recovery tool from here.
- Launch the device recovery tool.
- Remove all USB device.
- If possible switch off your phone. If not it is okay.
- Connect you phone via USB.
- In the device recovery tool, select Lumia and select My phone is not detected.
- The tool will automatically find your device.
- You will be having Install software instead of the reinstall as shown above. Click on that icon. The next screen will ask you for a reason. Provide one and click next. You will see the following screen.
- Click on Continue.
- Now it will download about 1.6GB-2GB for WP8.1 and 2.7GB for Windows 10 Mobile of files from the internet. Don't worry if it gets broken in the middle just hit retry it will resume from where it left.
- Then the new OS will be installed on the phone.
Note: For phone that came with Windows phone 8.1 only Windows Phone 8.1 will be installed and not Windows 10. You can update to Windows 10 later.
Images taken from : Windows Central article - Unenroll from Insider program