Sometimes you want/need to reset the git folder to complete new code. Rather than simply removing the folder and repository and creating new one, the following method solves the problem in couple of minutes. Follow the instructions, of course, at your own risk! I can simply assure you that I used it and it worked in my case.
So here it goes
If you aren’t in the same folder as your older code or you don’t have your code at all, then get it first!
git pull origin masterTo be sure that your are in master, git checkout to master. Then name the branch for the code, which you won’t need anymore (in this case, it is called old_stuff). Though it is not that necessary, it is recommended. In the end, push this branch to origin.
git checkout master
git branch old_stuff
git push origin old_stuffNow change to a new branch that you want to use (called new_stuff here)
git checkout -b new_stuffNow you are ready to remove all the old files you don’t need anymore
ls | xargs rm -rfCopy new files, which you are going to use, in the same folder
cp -r {SOURCE_LOCATION} .Add all the new copied files to git
git add -ACommit and push your new branch to origin
git commit
git push origin new_stuffNow update master for newer branch
git push . HEAD:masterFinally, push the newer version of master to origin
git push origin masterThat’s all. You had just reset your git, while still having your older code as old_stuff branch on remote origin. You can remove that branch anytime you want or keep it for future reviews.
Disclaimer: I am not responsible, if it creates any harm to your code or project. I would recommend you to understand each step, before you apply it. Best Luck!!!