git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* creating a new branch without an ancestor
@ 2010-02-05  3:19 Michael Wookey
  2010-02-05  3:24 ` Larry D'Anna
  2010-02-05 18:38 ` Wesley J. Landaker
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Wookey @ 2010-02-05  3:19 UTC (permalink / raw)
  To: Git Mailing List

Maybe I'm missing something from reading the docs, but I couldn't see
how to create a new branch in an existing repo that has no ancestor. I
would like to do something like what git.git does with some of the
other ancillary branches like "man", "html", and "todo".

I was hoping to do something like "git branch --no-ancestor
new-branch-name" but didn't see anything in the documentation that
describes the necessary branch options.

Or, am I looking in the wrong place?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: creating a new branch without an ancestor
  2010-02-05  3:19 creating a new branch without an ancestor Michael Wookey
@ 2010-02-05  3:24 ` Larry D'Anna
  2010-02-05  3:32   ` Jay Soffian
  2010-02-05 18:38 ` Wesley J. Landaker
  1 sibling, 1 reply; 4+ messages in thread
From: Larry D'Anna @ 2010-02-05  3:24 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Michael Wookey

* Michael Wookey (michaelwookey@gmail.com) [100204 22:20]:
> Maybe I'm missing something from reading the docs, but I couldn't see
> how to create a new branch in an existing repo that has no ancestor. I
> would like to do something like what git.git does with some of the
> other ancillary branches like "man", "html", and "todo".
> 
> I was hoping to do something like "git branch --no-ancestor
> new-branch-name" but didn't see anything in the documentation that
> describes the necessary branch options.
> 
> Or, am I looking in the wrong place?

git symbolic-ref HEAD refs/heads/whatever

That'll leave your index and working tree alone of course, so if you did a
commit right after that it would match the content of your current branch but
not the history.

    --larry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: creating a new branch without an ancestor
  2010-02-05  3:24 ` Larry D'Anna
@ 2010-02-05  3:32   ` Jay Soffian
  0 siblings, 0 replies; 4+ messages in thread
From: Jay Soffian @ 2010-02-05  3:32 UTC (permalink / raw)
  To: Larry D'Anna; +Cc: Git Mailing List, Michael Wookey

On Thu, Feb 4, 2010 at 10:24 PM, Larry D'Anna <larry@elder-gods.org> wrote:
> * Michael Wookey (michaelwookey@gmail.com) [100204 22:20]:
>> Maybe I'm missing something from reading the docs, but I couldn't see
>> how to create a new branch in an existing repo that has no ancestor. I
>> would like to do something like what git.git does with some of the
>> other ancillary branches like "man", "html", and "todo".
>>
>> I was hoping to do something like "git branch --no-ancestor
>> new-branch-name" but didn't see anything in the documentation that
>> describes the necessary branch options.
>>
>> Or, am I looking in the wrong place?
>
> git symbolic-ref HEAD refs/heads/whatever
>
> That'll leave your index and working tree alone of course, so if you did a
> commit right after that it would match the content of your current branch but
> not the history.

You can also create the branch in a new repo, then just fetch that
into your existing repo.

j.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: creating a new branch without an ancestor
  2010-02-05  3:19 creating a new branch without an ancestor Michael Wookey
  2010-02-05  3:24 ` Larry D'Anna
@ 2010-02-05 18:38 ` Wesley J. Landaker
  1 sibling, 0 replies; 4+ messages in thread
From: Wesley J. Landaker @ 2010-02-05 18:38 UTC (permalink / raw)
  To: Michael Wookey; +Cc: Git Mailing List

On Thu, February 4, 2010 20:19, Michael Wookey wrote:
> Maybe I'm missing something from reading the docs, but I couldn't see
> how to create a new branch in an existing repo that has no ancestor. I
> would like to do something like what git.git does with some of the
> other ancillary branches like "man", "html", and "todo".
>
> I was hoping to do something like "git branch --no-ancestor
> new-branch-name" but didn't see anything in the documentation that
> describes the necessary branch options.
>
> Or, am I looking in the wrong place?

I do this all the time for various reasons, so I made myself a
"git-emptybranch" command and stuck it in my path. Besides the error
checking, this just creates a new ref and clears the index so you can
start from a clean slate. No actual files are deleted from the work-tree.

$ cat ~/bin/git-emptybranch
#!/bin/sh
if [ $# -ne 1 ]; then
  2<&1
  echo "usage: git emptybranch <new_branch>"
  exit 1
fi

if ! git check-ref-format refs/heads/"$1"; then
  2<&1
  echo "fatal: '$1' is not a valid branch name."
  exit 1
fi

git symbolic-ref -m "git emptybranch $1" HEAD refs/heads/"$1"
git rm --cached -r -q --ignore-unmatch -- '*'

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-02-05 18:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-05  3:19 creating a new branch without an ancestor Michael Wookey
2010-02-05  3:24 ` Larry D'Anna
2010-02-05  3:32   ` Jay Soffian
2010-02-05 18:38 ` Wesley J. Landaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).