git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* reverting initial commit
@ 2009-03-25 18:12 Pascal Obry
  2009-03-25 18:20 ` Jacob Helwig
  2009-03-25 18:26 ` Junio C Hamano
  0 siblings, 2 replies; 10+ messages in thread
From: Pascal Obry @ 2009-03-25 18:12 UTC (permalink / raw)
  To: git list


Starting a new project I create a new repo and added some files for the
initial revision of the project, something like:

mkdir repo.git
cd repo.git
git init
touch file
git add file
git ci -m "initial revision"

Now one file was not meant to be committed, I wanted to revert this commit:

git reset HEAD^

fatal: ambiguous argument 'HEAD^': unknown revision or path not in the
working tree.
Use '--' to separate paths from revisions

I understand that HEAD^ does not exist, is there a way to do that?

Thanks,
Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B

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

* Re: reverting initial commit
  2009-03-25 18:12 reverting initial commit Pascal Obry
@ 2009-03-25 18:20 ` Jacob Helwig
  2009-03-25 18:26 ` Junio C Hamano
  1 sibling, 0 replies; 10+ messages in thread
From: Jacob Helwig @ 2009-03-25 18:20 UTC (permalink / raw)
  To: pascal; +Cc: git list

On Wed, Mar 25, 2009 at 11:12, Pascal Obry <pascal@obry.net> wrote:
>
> Starting a new project I create a new repo and added some files for the
> initial revision of the project, something like:
>
> mkdir repo.git
> cd repo.git
> git init
> touch file
> git add file
> git ci -m "initial revision"
>
> Now one file was not meant to be committed, I wanted to revert this commit:
>
> git reset HEAD^
>
> fatal: ambiguous argument 'HEAD^': unknown revision or path not in the
> working tree.
> Use '--' to separate paths from revisions
>
> I understand that HEAD^ does not exist, is there a way to do that?
>
> Thanks,
> Pascal.
>
> --
>
> --|------------------------------------------------------
> --| Pascal Obry                           Team-Ada Member
> --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
> --|------------------------------------------------------
> --|    http://www.obry.net  -  http://v2p.fr.eu.org
> --| "The best way to travel is by means of imagination"
> --|
> --| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
>
> --
> 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
>

You want "git filter-branch".  Probably something like:

git filter-branch --index-filter 'git rm --cached --ignore-unmatched
FILE_TO_REMOVE' -- --all

This will remove FILE_TO_REMOVE from all commits across all branches.

-Jacob

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

* Re: reverting initial commit
  2009-03-25 18:12 reverting initial commit Pascal Obry
  2009-03-25 18:20 ` Jacob Helwig
@ 2009-03-25 18:26 ` Junio C Hamano
  2009-03-25 18:33   ` Jacob Helwig
  2009-03-25 18:36   ` Pascal Obry
  1 sibling, 2 replies; 10+ messages in thread
From: Junio C Hamano @ 2009-03-25 18:26 UTC (permalink / raw)
  To: pascal; +Cc: git list

Pascal Obry <pascal@obry.net> writes:

> Starting a new project I create a new repo and added some files for the
> initial revision of the project, something like:
>
> mkdir repo.git
> cd repo.git
> git init
> touch file
> git add file
> git ci -m "initial revision"
>
> Now one file was not meant to be committed, I wanted to revert this commit:

That's not even an revert.  Can't you simply amend it away?

	$ git rm not-this-file
        $ git commit --amend

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

* Re: reverting initial commit
  2009-03-25 18:26 ` Junio C Hamano
@ 2009-03-25 18:33   ` Jacob Helwig
  2009-03-25 19:45     ` Giuseppe Bilotta
  2009-03-25 18:36   ` Pascal Obry
  1 sibling, 1 reply; 10+ messages in thread
From: Jacob Helwig @ 2009-03-25 18:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: pascal, git list

On Wed, Mar 25, 2009 at 11:26, Junio C Hamano <gitster@pobox.com> wrote:
> Pascal Obry <pascal@obry.net> writes:
>
>> Starting a new project I create a new repo and added some files for the
>> initial revision of the project, something like:
>>
>> mkdir repo.git
>> cd repo.git
>> git init
>> touch file
>> git add file
>> git ci -m "initial revision"
>>
>> Now one file was not meant to be committed, I wanted to revert this commit:
>
> That's not even an revert.  Can't you simply amend it away?
>
>        $ git rm not-this-file
>        $ git commit --amend
> --
> 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
>

This is obviously the easier way.  (Or a rebase --interactive)  I've
just got filter-branch on the brain, because of a git conversion.

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

* Re: reverting initial commit
  2009-03-25 18:26 ` Junio C Hamano
  2009-03-25 18:33   ` Jacob Helwig
@ 2009-03-25 18:36   ` Pascal Obry
  2009-03-25 18:40     ` Junio C Hamano
  1 sibling, 1 reply; 10+ messages in thread
From: Pascal Obry @ 2009-03-25 18:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git list

Junio C Hamano a écrit :
> That's not even an revert.  

Right.

> Can't you simply amend it away?
> 
> 	$ git rm not-this-file
>         $ git commit --amend

Right, I've done that. But the fact that un-committing the initial
commit was not possible seemed strange to me. At least the error message
should be clearer, don't you think?

Thanks.
Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B

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

* Re: reverting initial commit
  2009-03-25 18:36   ` Pascal Obry
@ 2009-03-25 18:40     ` Junio C Hamano
  0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2009-03-25 18:40 UTC (permalink / raw)
  To: pascal; +Cc: git list

Pascal Obry <pascal@obry.net> writes:

> Junio C Hamano a écrit :
>> That's not even an revert.  
>
> Right.
>
>> Can't you simply amend it away?
>> 
>> 	$ git rm not-this-file
>>         $ git commit --amend
>
> Right, I've done that. But the fact that un-committing the initial
> commit was not possible seemed strange to me. At least the error message
> should be clearer, don't you think?

"You said HEAD^ but there is no such thing?  What are you talking about?"

That sounds clear enough to me, but if you have a patch to improve it,
please send it in.

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

* Re: reverting initial commit
  2009-03-25 18:33   ` Jacob Helwig
@ 2009-03-25 19:45     ` Giuseppe Bilotta
  2009-03-25 20:40       ` Sverre Rabbelier
  2009-03-25 21:06       ` Eric Raible
  0 siblings, 2 replies; 10+ messages in thread
From: Giuseppe Bilotta @ 2009-03-25 19:45 UTC (permalink / raw)
  To: git

On Wednesday 25 March 2009 19:33, Jacob Helwig wrote:
> On Wed, Mar 25, 2009 at 11:26, Junio C Hamano <gitster@pobox.com> wrote:
>>
>> That's not even an revert.  Can't you simply amend it away?
>>
>>        $ git rm not-this-file
>>        $ git commit --amend
> 
> This is obviously the easier way.  (Or a rebase --interactive)

Actually, rebase --interactive cannot be used to amend the first commit.
This is something that has hit me a couple of times when I realised, after
the second or third commit, that I needed to fix the first one. I found
the fastest way in this case to be to just format-patch all but the first
commit, reset --hard to the first commit, amend, and git am what I format-
patched.

I wish there was a way to tell rebase -i to go back to the first commit,
inclusive, but the two or three times I've tried hacking at it I never
managed to come to anything useful 8-/

-- 
Giuseppe "Oblomov" Bilotta

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

* Re: reverting initial commit
  2009-03-25 19:45     ` Giuseppe Bilotta
@ 2009-03-25 20:40       ` Sverre Rabbelier
  2009-03-25 21:22         ` Giuseppe Bilotta
  2009-03-25 21:06       ` Eric Raible
  1 sibling, 1 reply; 10+ messages in thread
From: Sverre Rabbelier @ 2009-03-25 20:40 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git

Heya,

On Wed, Mar 25, 2009 at 20:45, Giuseppe Bilotta
<giuseppe.bilotta@gmail.com> wrote:
> I wish there was a way to tell rebase -i to go back to the first commit,
> inclusive, but the two or three times I've tried hacking at it I never
> managed to come to anything useful 8-/

Wasn't --root added to rebase -i recently?

-- 
Cheers,

Sverre Rabbelier

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

* Re: reverting initial commit
  2009-03-25 19:45     ` Giuseppe Bilotta
  2009-03-25 20:40       ` Sverre Rabbelier
@ 2009-03-25 21:06       ` Eric Raible
  1 sibling, 0 replies; 10+ messages in thread
From: Eric Raible @ 2009-03-25 21:06 UTC (permalink / raw)
  To: git

Giuseppe Bilotta <giuseppe.bilotta <at> gmail.com> writes:

> Actually, rebase --interactive cannot be used to amend the first commit.
> This is something that has hit me a couple of times when I realised, after
> the second or third commit, that I needed to fix the first one. I found
> the fastest way in this case to be to just format-patch all but the first
> commit, reset --hard to the first commit, amend, and git am what I format-
> patched.
> 
> I wish there was a way to tell rebase -i to go back to the first commit,
> inclusive, but the two or three times I've tried hacking at it I never
> managed to come to anything useful 8-/

I like to be able to rebase -i back to the first commit as well,
which is why I generally start off with:

git init && git commit --allow-empty -m'initial commit'

- Eric

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

* Re: reverting initial commit
  2009-03-25 20:40       ` Sverre Rabbelier
@ 2009-03-25 21:22         ` Giuseppe Bilotta
  0 siblings, 0 replies; 10+ messages in thread
From: Giuseppe Bilotta @ 2009-03-25 21:22 UTC (permalink / raw)
  To: Sverre Rabbelier; +Cc: git

On Wed, Mar 25, 2009 at 9:40 PM, Sverre Rabbelier <srabbelier@gmail.com> wrote:
> Heya,
>
> On Wed, Mar 25, 2009 at 20:45, Giuseppe Bilotta
> <giuseppe.bilotta@gmail.com> wrote:
>> I wish there was a way to tell rebase -i to go back to the first commit,
>> inclusive, but the two or three times I've tried hacking at it I never
>> managed to come to anything useful 8-/
>
> Wasn't --root added to rebase -i recently?

>From reading the manpage I assumed it could only be used to put the
stuff on top of something else (the --onto requirement). Or did I miss
something along the way?


-- 
Giuseppe "Oblomov" Bilotta

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

end of thread, other threads:[~2009-03-25 21:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-25 18:12 reverting initial commit Pascal Obry
2009-03-25 18:20 ` Jacob Helwig
2009-03-25 18:26 ` Junio C Hamano
2009-03-25 18:33   ` Jacob Helwig
2009-03-25 19:45     ` Giuseppe Bilotta
2009-03-25 20:40       ` Sverre Rabbelier
2009-03-25 21:22         ` Giuseppe Bilotta
2009-03-25 21:06       ` Eric Raible
2009-03-25 18:36   ` Pascal Obry
2009-03-25 18:40     ` Junio C Hamano

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).