{"thread":{"id":"22528","subject":"Re: creating a new branch without an ancestor","startedAt":"2010-02-05T03:19:12Z","lastAt":"2010-02-05T18:38:31Z","messageCount":4,"participants":["Jay Soffian","Larry D'Anna","Michael Wookey","Wesley J. Landaker"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"133663","messageId":"d2e97e801002041919r2043d05cjfb114a466605d9a1@mail.gmail.com","threadId":"22528","inReplyTo":null,"subject":"creating a new branch without an ancestor","fromName":"Michael Wookey","fromEmail":"michaelwookey@gmail.com","sentAt":"2010-02-05T03:19:12Z","receivedAt":"2010-02-05T03:19:12Z","isPatch":false,"sender":{"key":"michaelwookey@gmail.com","avatar":"https://avatars.githubusercontent.com/u/19476?v=4"},"body":"Maybe I'm missing something from reading the docs, but I couldn't see\nhow to create a new branch in an existing repo that has no ancestor. I\nwould like to do something like what git.git does with some of the\nother ancillary branches like \"man\", \"html\", and \"todo\".\n\nI was hoping to do something like \"git branch --no-ancestor\nnew-branch-name\" but didn't see anything in the documentation that\ndescribes the necessary branch options.\n\nOr, am I looking in the wrong place?\n"},{"id":"133661","messageId":"20100205032429.GA23285@cthulhu","threadId":"22528","inReplyTo":"d2e97e801002041919r2043d05cjfb114a466605d9a1@mail.gmail.com","subject":"Re: creating a new branch without an ancestor","fromName":"Larry D'Anna","fromEmail":"larry@elder-gods.org","sentAt":"2010-02-05T03:24:29Z","receivedAt":"2010-02-05T03:24:29Z","isPatch":false,"sender":{"key":"larry@elder-gods.org","avatar":"https://avatars.githubusercontent.com/u/3013304?v=4"},"body":"* Michael Wookey (michaelwookey@gmail.com) [100204 22:20]:\n> Maybe I'm missing something from reading the docs, but I couldn't see\n> how to create a new branch in an existing repo that has no ancestor. I\n> would like to do something like what git.git does with some of the\n> other ancillary branches like \"man\", \"html\", and \"todo\".\n> \n> I was hoping to do something like \"git branch --no-ancestor\n> new-branch-name\" but didn't see anything in the documentation that\n> describes the necessary branch options.\n> \n> Or, am I looking in the wrong place?\n\ngit symbolic-ref HEAD refs/heads/whatever\n\nThat'll leave your index and working tree alone of course, so if you did a\ncommit right after that it would match the content of your current branch but\nnot the history.\n\n    --larry\n"},{"id":"133660","messageId":"76718491002041932m3398abdel85bd1f4e1eb96899@mail.gmail.com","threadId":"22528","inReplyTo":"20100205032429.GA23285@cthulhu","subject":"Re: creating a new branch without an ancestor","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-02-05T03:32:43Z","receivedAt":"2010-02-05T03:32:43Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Feb 4, 2010 at 10:24 PM, Larry D'Anna <larry@elder-gods.org> wrote:\n> * Michael Wookey (michaelwookey@gmail.com) [100204 22:20]:\n>> Maybe I'm missing something from reading the docs, but I couldn't see\n>> how to create a new branch in an existing repo that has no ancestor. I\n>> would like to do something like what git.git does with some of the\n>> other ancillary branches like \"man\", \"html\", and \"todo\".\n>>\n>> I was hoping to do something like \"git branch --no-ancestor\n>> new-branch-name\" but didn't see anything in the documentation that\n>> describes the necessary branch options.\n>>\n>> Or, am I looking in the wrong place?\n>\n> git symbolic-ref HEAD refs/heads/whatever\n>\n> That'll leave your index and working tree alone of course, so if you did a\n> commit right after that it would match the content of your current branch but\n> not the history.\n\nYou can also create the branch in a new repo, then just fetch that\ninto your existing repo.\n\nj.\n"},{"id":"133700","messageId":"80b2e7a2e4025acdad6e869fdeb9aab7.squirrel@webmail.icecavern.net","threadId":"22528","inReplyTo":"d2e97e801002041919r2043d05cjfb114a466605d9a1@mail.gmail.com","subject":"Re: creating a new branch without an ancestor","fromName":"Wesley J. Landaker","fromEmail":"wjl@icecavern.net","sentAt":"2010-02-05T18:38:31Z","receivedAt":"2010-02-05T18:38:31Z","isPatch":false,"sender":{"key":"wjl@icecavern.net","avatar":"https://avatars.githubusercontent.com/u/67229?v=4"},"body":"On Thu, February 4, 2010 20:19, Michael Wookey wrote:\n> Maybe I'm missing something from reading the docs, but I couldn't see\n> how to create a new branch in an existing repo that has no ancestor. I\n> would like to do something like what git.git does with some of the\n> other ancillary branches like \"man\", \"html\", and \"todo\".\n>\n> I was hoping to do something like \"git branch --no-ancestor\n> new-branch-name\" but didn't see anything in the documentation that\n> describes the necessary branch options.\n>\n> Or, am I looking in the wrong place?\n\nI do this all the time for various reasons, so I made myself a\n\"git-emptybranch\" command and stuck it in my path. Besides the error\nchecking, this just creates a new ref and clears the index so you can\nstart from a clean slate. No actual files are deleted from the work-tree.\n\n$ cat ~/bin/git-emptybranch\n#!/bin/sh\nif [ $# -ne 1 ]; then\n  2<&1\n  echo \"usage: git emptybranch <new_branch>\"\n  exit 1\nfi\n\nif ! git check-ref-format refs/heads/\"$1\"; then\n  2<&1\n  echo \"fatal: '$1' is not a valid branch name.\"\n  exit 1\nfi\n\ngit symbolic-ref -m \"git emptybranch $1\" HEAD refs/heads/\"$1\"\ngit rm --cached -r -q --ignore-unmatch -- '*'\n"}]}