Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move prototype code out of master branch with git

Tags:

git

The master branch of a new project's git repo contains only prototype/spike code. I'm about to re-start the coding from scratch, now that I have the basic ideas understood.

I want the master branch to be clear of all the prototype code. Ideally the prototype code needs to be moved into a branch so I can still get to it later.

Is it possible to reset master back to before the first commit? What are the git commands to do this?

like image 570
Andrew Davey Avatar asked Dec 17 '22 13:12

Andrew Davey


2 Answers

If you're really going to start from scratch, just create a completely new repository. It's possible to have two branches without any common ancestor, but it's not really that useful.

like image 70
Greg Hewgill Avatar answered Dec 19 '22 08:12

Greg Hewgill


This is how you create a new branch not sharing any history with your other branches: How to create a new empty branch for a new project.

Before following these instructions, just rename your existing master to prototype using git branch -m master prototype. Then, when following the linked instructions, use master instead of newbranch.

like image 33
Tilman Vogel Avatar answered Dec 19 '22 07:12

Tilman Vogel