threads / discuss / 21360

git rebase -i <first_commit_in_repository>

Subject: git rebase -i <first_commit_in_repository>

## tl;dr

9 messages between Oct 26, 2009 and Oct 28, 2009.

replies: 8people: 6as markdown or json

eschvoca· Oct 26, 2009, 17:14 UTC · lore
Hi,

Is there a way to rewrite history, including the first commit. It seems that the first commit can not be modified with a rebase.

Cheers.
Mike Hommey· Oct 26, 2009, 17:24 UTC · re: eschvoca · lore

Re: git rebase -i <first_commit_in_repository>

On Mon, Oct 26, 2009 at 01:14:47PM -0400, eschvoca wrote:
> Hi,
> 
> Is there a way to rewrite history, including the first commit.  It
> seems that the first commit can not be modified with a rebase.

Unfortunately, there is no way to do so, except by hand, by checking out the first commit, amend it, and then rebase.

Mike
Erik Faye-Lund· Oct 26, 2009, 17:25 UTC · re: eschvoca · lore

Re: git rebase -i <first_commit_in_repository>

On Mon, Oct 26, 2009 at 6:14 PM, eschvoca <eschvoca@gmail.com> wrote:
> Hi,
>
> Is there a way to rewrite history, including the first commit.  It
> seems that the first commit can not be modified with a rebase.

This question is answered in the FAQ: http://git.or.cz/gitwiki/GitFaq#HowdoIedittherootcommit.3F

-- 
Erik "kusma" Faye-Lund
eschvoca· Oct 26, 2009, 18:08 UTC · re: Erik Faye-Lund · lore

Re: git rebase -i <first_commit_in_repository>

On Mon, Oct 26, 2009 at 1:25 PM, Erik Faye-Lund <kusmabite@googlemail.com> wrote:

Show 9 quoted lines
> On Mon, Oct 26, 2009 at 6:14 PM, eschvoca <eschvoca@gmail.com> wrote:
>> Hi,
>>
>> Is there a way to rewrite history, including the first commit.  It
>> seems that the first commit can not be modified with a rebase.
>
> This question is answered in the FAQ:
> http://git.or.cz/gitwiki/GitFaq#HowdoIedittherootcommit.3F
>
Thanks Eric.  Hopefully someone will enhance rebase to handle the root commit.
Dirk Süsserott· Oct 26, 2009, 20:28 UTC · re: eschvoca · lore

Re: git rebase -i <first_commit_in_repository>

Am 26.10.2009 19:08 schrieb eschvoca:
Show 12 quoted lines
> On Mon, Oct 26, 2009 at 1:25 PM, Erik Faye-Lund
> <kusmabite@googlemail.com> wrote:
>> On Mon, Oct 26, 2009 at 6:14 PM, eschvoca <eschvoca@gmail.com> wrote:
>>> Hi,
>>>
>>> Is there a way to rewrite history, including the first commit.  It
>>> seems that the first commit can not be modified with a rebase.
>> This question is answered in the FAQ:
>> http://git.or.cz/gitwiki/GitFaq#HowdoIedittherootcommit.3F
>>
> 
> Thanks Eric.  Hopefully someone will enhance rebase to handle the root commit.
Hi,

probably my approach could help you in the future: When I create a new repo (git init) I firstly create an initial commit with nothing else than an initial commit, i.e.:

$ git init $ echo "initial" > initial.commit $ git add initial.commit $ git commit -m "Initial commit"

and then secondly

$ git add . $ git commit -m "*REAL* initial commit"

Afterwards I have a repo with an initial commit that only contains one file (initial.commit) and the "real" initial commits thereafter. Maybe that's a solution for you.

Cheers,
     Dirk
Allan Caffee· Oct 26, 2009, 20:47 UTC · re: Dirk Süsserott · lore

Re: git rebase -i <first_commit_in_repository>

2009/10/26 Dirk Süsserott <newsletter@dirk.my1.cc>:
Show 11 quoted lines
> Am 26.10.2009 19:08 schrieb eschvoca:
> Hi,
>
> probably my approach could help you in the future: When I create a new repo
> (git init) I firstly create an initial commit with nothing else than an
> initial commit, i.e.:
>
> $ git init
> $ echo "initial" > initial.commit
> $ git add initial.commit
> $ git commit -m "Initial commit"

I don't think this is actually necessary. You should just be able to do: $ git init $ git commit --allow-empty -m "Initial commit (empty)"

-- Allan

Dirk Süsserott· Oct 28, 2009, 19:24 UTC · re: Allan Caffee · lore

Re: git rebase -i <first_commit_in_repository>

Am 26.10.2009 21:47 schrieb Allan Caffee:
Show 17 quoted lines
> 2009/10/26 Dirk Süsserott <newsletter@dirk.my1.cc>:
>> Am 26.10.2009 19:08 schrieb eschvoca:
>> Hi,
>>
>> probably my approach could help you in the future: When I create a new repo
>> (git init) I firstly create an initial commit with nothing else than an
>> initial commit, i.e.:
>>
>> $ git init
>> $ echo "initial" > initial.commit
>> $ git add initial.commit
>> $ git commit -m "Initial commit"
> 
> I don't think this is actually necessary.  You should just be able to do:
> $ git init
> $ git commit --allow-empty -m "Initial commit (empty)"
> 
Allan,

that works great and is not as cumbersome as my solution. Thank you!

Dirk
Johannes Schindelin· Oct 26, 2009, 21:11 UTC · re: eschvoca · lore

Re: git rebase -i <first_commit_in_repository>

Hi,
On Mon, 26 Oct 2009, eschvoca wrote:
Show 13 quoted lines
> On Mon, Oct 26, 2009 at 1:25 PM, Erik Faye-Lund
> <kusmabite@googlemail.com> wrote:
> > On Mon, Oct 26, 2009 at 6:14 PM, eschvoca <eschvoca@gmail.com> wrote:
> >> Hi,
> >>
> >> Is there a way to rewrite history, including the first commit.  It
> >> seems that the first commit can not be modified with a rebase.
> >
> > This question is answered in the FAQ:
> > http://git.or.cz/gitwiki/GitFaq#HowdoIedittherootcommit.3F
> 
> Thanks Eric.  Hopefully someone will enhance rebase to handle the root 
> commit.

If you cannot do it yourself, you can always offer to bribe^Wpay somebody to do it for you.

Ciao, Dscho

eschvoca· Oct 27, 2009, 00:27 UTC · re: Johannes Schindelin · lore

Re: git rebase -i <first_commit_in_repository>

Hi,

On Mon, Oct 26, 2009 at 5:11 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 24 quoted lines
> Hi,
>
> On Mon, 26 Oct 2009, eschvoca wrote:
>
>> On Mon, Oct 26, 2009 at 1:25 PM, Erik Faye-Lund
>> <kusmabite@googlemail.com> wrote:
>> > On Mon, Oct 26, 2009 at 6:14 PM, eschvoca <eschvoca@gmail.com> wrote:
>> >> Hi,
>> >>
>> >> Is there a way to rewrite history, including the first commit.  It
>> >> seems that the first commit can not be modified with a rebase.
>> >
>> > This question is answered in the FAQ:
>> > http://git.or.cz/gitwiki/GitFaq#HowdoIedittherootcommit.3F
>>
>> Thanks Eric.  Hopefully someone will enhance rebase to handle the root
>> commit.
>
> If you cannot do it yourself, you can always offer to bribe^Wpay somebody
> to do it for you.
>
> Ciao,
> Dscho
>

I can do the workaround myself but not the production ready patch. Right now the only bribe I can offer is that it might be less work writing the patch than supporting this corner case with answering questions and writing a FAQ entry about it. It also would make the awesome rebase -i even awesomer :) I know, a disappointing bribe but from a thankful user.

Thanks

← back to recent threads