2

I have a prototype version of an app in a repo.

I'd like to store the code from this prototype for future reference but not include any of the files in the next release version of the code which I'll start form scratch on a new branch.

So far, I've created a new branch for the prototype and pushed that to our remote repository - that's safe and not going anywhere.

Back on my local, master branch I'd like to start with a completely clean slate - remove all the files currently listed.

Is there a more gitish way to approach this than simply removing the files?

I remember there was a method I used previously when setting up github pages for a repository but the documentation for that seems to have moved :/

Thanks in advance

4

1 回答 1

2

Here's a blog post on creating a branch without ancestry. It describes two possible ways, you can try both and see which one works better for you.

In summary now that the original link is dead:

The simplest method of creating a new git branch without any ancestors:

$ echo ref: refs/heads/newbranch > .git/HEAD
$ git branch
  master
[...]
$ git commit -m 'creating newbranch'
$ git branch
  master
* newbranch

Another option is:

$ git symbolic-ref HEAD refs/heads/newbranch
[...]

Which doesn't touch any files in .git

于 2012-07-03T15:17:54.753 回答