git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: reverting initial commit

From
Jacob Helwig <jacob.helwig@gmail.com>
Date
Mar 25, 2009, 18:20 UTC
Message-ID
<8c9a060903251120j3e757e94o96b2b77669c16c61@mail.gmail.com>
In-Reply-To
<49CA7428.70400@obry.net>
On Wed, Mar 25, 2009 at 11:12, Pascal Obry <pascal@obry.net> wrote:
Show 40 quoted lines
>
> 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
Previous: Pascal ObryNext: Junio C Hamano
Message 2 of 10 in “reverting initial commit”
  1. Pascal ObryMar 25, 2009
  2. Jacob HelwigMar 25, 2009
  3. Junio C HamanoMar 25, 2009
  4. Jacob HelwigMar 25, 2009
  5. Giuseppe BilottaMar 25, 2009
  6. Sverre RabbelierMar 25, 2009
  7. Giuseppe BilottaMar 25, 2009
  8. Eric RaibleMar 25, 2009
  9. Pascal ObryMar 25, 2009
  10. Junio C HamanoMar 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.