开发者

Move prototype code out of master branch with git

The master branch of a new project's git repo co开发者_JAVA技巧ntains 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?


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.


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.


  1. From the current master branch, make a new branch with your prototype code. git checkout -b prototype.
  2. Get back to the master branch with git checkout master.
  3. Remove all the files from the master branch with git rm -rf *.
  4. Commit your changes on the master branch with git commit -m "Removed prototype code".

This way, the history will be kept and you can always track in the log when the switch took place.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜