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!
To 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
.
Now change to a new branch that you want to use (called new_stuff
here)
Now you are ready to remove all the old files you don’t need anymore
Copy new files, which you are going to use, in the same folder
Add all the new copied files to git
Commit and push your new branch to origin
Now update master
for newer branch
Finally, push the newer version of master to origin
That’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!!!