# `git checkout --orpan` leaves a dirty worktree

8 messages from 2013-02-08 to 2013-02-10. Participants: Ramkumar Ramachandra, Jonathan Nieder, Junio C Hamano, Martin von Zweigbergk, Jens Lehmann.
Thread: https://gitlist.dev/t/32860

## Ramkumar Ramachandra, 2013-02-08 19:50

Subject: `git checkout --orpan` leaves a dirty worktree
Message-ID: <CALkWK0mjf5vsiHvMW-QyzMHdmZQvdzjw_ORJnMd=mT6RCqB1xg@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0mjf5vsiHvMW-QyzMHdmZQvdzjw_ORJnMd%3DmT6RCqB1xg%40mail.gmail.com

```
Hi,

Why should I have to `git rm -rf .` after a `git checkout --orphan`?
What sort of misfeature/ incomplete feature is this?

Ram

```

## Jonathan Nieder, 2013-02-08 20:04

Subject: Re: `git checkout --orpan` leaves a dirty worktree
Message-ID: <20130208200402.GB8461@google.com>
URL: https://gitlist.dev/e/20130208200402.GB8461%40google.com
In-Reply-To: <CALkWK0mjf5vsiHvMW-QyzMHdmZQvdzjw_ORJnMd=mT6RCqB1xg@mail.gmail.com>

```
Ramkumar Ramachandra wrote:

> Why should I have to `git rm -rf .` after a `git checkout --orphan`?
> What sort of misfeature/ incomplete feature is this?

One designed for the "going open source" use case, where you have
existing code that you want to put into a new branch without history.
When there is no existing code, it seems simpler to do

	cd ..
	git init code-that-has-nothing-to-do-previous-cwd
	cd code-that-*
	... hack hack hack ...
	git commit
	git remote add origin <url>
	git push -u origin master

BTW, I suspect a clearer way to say what you meant is "Sounds like a
misfeature" which is gentler and more focused than an implied "What
kind of idiot designed this?"  Even if you are thinking the latter. :)

Hope that helps,
Jonathan

```

## Ramkumar Ramachandra, 2013-02-08 20:11

Subject: Re: `git checkout --orpan` leaves a dirty worktree
Message-ID: <CALkWK0mdLabT7XyuYsDCROBC5FX+tDgyMnjMRbdkO41PTWd_Ug@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0mdLabT7XyuYsDCROBC5FX%2BtDgyMnjMRbdkO41PTWd_Ug%40mail.gmail.com
In-Reply-To: <20130208200402.GB8461@google.com>

```
Jonathan Nieder wrote:
> Ramkumar Ramachandra wrote:
> One designed for the "going open source" use case, where you have
> existing code that you want to put into a new branch without history.

> BTW, I suspect a clearer way to say what you meant is "Sounds like a
> misfeature" which is gentler and more focused than an implied "What
> kind of idiot designed this?"  Even if you are thinking the latter. :)

Yes, I do feel stupid now.

BTW, Is there a better way to clean out the worktree than `git rm -rf
.`, since that fails for submodules?  The impulsive `reset --hard`
obviously fails because there is no HEAD.

Thanks.

```

## Junio C Hamano, 2013-02-08 20:12

Subject: Re: `git checkout --orpan` leaves a dirty worktree
Message-ID: <7vzjzezhrr.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzjzezhrr.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20130208200402.GB8461@google.com>

```
Jonathan Nieder <jrnieder@gmail.com> writes:

> Ramkumar Ramachandra wrote:
>
>> Why should I have to `git rm -rf .` after a `git checkout --orphan`?
>> What sort of misfeature/ incomplete feature is this?
>
> One designed for the "going open source" use case, where you have
> existing code that you want to put into a new branch without history.
> When there is no existing code, it seems simpler to do
>
> 	cd ..
> 	git init code-that-has-nothing-to-do-previous-cwd
> 	cd code-that-*
> 	... hack hack hack ...
> 	git commit
> 	git remote add origin <url>
> 	git push -u origin master
>
> BTW, I suspect a clearer way to say what you meant is "Sounds like a
> misfeature" which is gentler and more focused than an implied "What
> kind of idiot designed this?"  Even if you are thinking the latter. :)

So true ;-).  

Especially when you may an answer that may make _you_ look like an
idiot ;-)

```

## Junio C Hamano, 2013-02-08 20:17

Subject: Re: `git checkout --orpan` leaves a dirty worktree
Message-ID: <7vvca2zhkb.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vvca2zhkb.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CALkWK0mdLabT7XyuYsDCROBC5FX+tDgyMnjMRbdkO41PTWd_Ug@mail.gmail.com>

```
Ramkumar Ramachandra <artagnon@gmail.com> writes:

> BTW, Is there a better way to clean out the worktree than `git rm -rf
> .`, since that fails for submodules?  The impulsive `reset --hard`
> obviously fails because there is no HEAD.

I _think_ the "git rm" is one of the things on Jens's roadmap.  Also
I think "reset --hard" these days does know what to do when you do
not have any history yet.

```

## Martin von Zweigbergk, 2013-02-08 20:31

Subject: Re: `git checkout --orpan` leaves a dirty worktree
Message-ID: <CANiSa6hD=zX5=evziqQpXHdjUDEU80t_Du7L+Hpa11ru=5XVNQ@mail.gmail.com>
URL: https://gitlist.dev/e/CANiSa6hD%3DzX5%3DevziqQpXHdjUDEU80t_Du7L%2BHpa11ru%3D5XVNQ%40mail.gmail.com
In-Reply-To: <CALkWK0mjf5vsiHvMW-QyzMHdmZQvdzjw_ORJnMd=mT6RCqB1xg@mail.gmail.com>

```
I'm curious what your use case is.

The behavior has been inconvenient for me too, but I have only used it
in test cases; I have no real use case where I wanted to create an
unborn/orphan branch.

On Fri, Feb 8, 2013 at 11:50 AM, Ramkumar Ramachandra
<artagnon@gmail.com> wrote:
> Hi,
>
> Why should I have to `git rm -rf .` after a `git checkout --orphan`?
> What sort of misfeature/ incomplete feature is this?
>
> Ram
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

```

## Ramkumar Ramachandra, 2013-02-08 20:38

Subject: Re: `git checkout --orpan` leaves a dirty worktree
Message-ID: <CALkWK0mcOjbzCvzc-1W9RYM878Tiy8m20T41SdvqgY=qtE67rA@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0mcOjbzCvzc-1W9RYM878Tiy8m20T41SdvqgY%3DqtE67rA%40mail.gmail.com
In-Reply-To: <CANiSa6hD=zX5=evziqQpXHdjUDEU80t_Du7L+Hpa11ru=5XVNQ@mail.gmail.com>

```
Martin von Zweigbergk wrote:
> I'm curious what your use case is.

A couple of them off the top of my head: the gh-pages branch in
GitHub, restarting a project but keeping the old history around for
reference.

```

## Jens Lehmann, 2013-02-10 20:10

Subject: Re: `git checkout --orpan` leaves a dirty worktree
Message-ID: <5117FEC5.8080109@web.de>
URL: https://gitlist.dev/e/5117FEC5.8080109%40web.de
In-Reply-To: <7vvca2zhkb.fsf@alter.siamese.dyndns.org>

```
Am 08.02.2013 21:17, schrieb Junio C Hamano:
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
> 
>> BTW, Is there a better way to clean out the worktree than `git rm -rf
>> .`, since that fails for submodules?  The impulsive `reset --hard`
>> obviously fails because there is no HEAD.
> 
> I _think_ the "git rm" is one of the things on Jens's roadmap.

Hmm, "git rm" does remove submodules since 1.8.1 (but they have to be
cloned with Git 1.7.8 or newer). Or is there something special about
the orphan checkout I'm missing here?

```
