How to restore your iPhone to its original state?

So I did something really stupid. I plugged my new phone into my laptop and it automatically backed up my new phone with my old files and I lost everything I had before like contacts, messages etc. Now I want it to go back to its original state where I still have my stuff on it. So help is appreciated!

Use either I tunes or the menu to choose erase all and restore to original factory settings