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

Re: I want delete fault commit from my git repository

From
Jakub Narebski <jnareb@gmail.com>
Date
Jul 14, 2008, 16:41 UTC
Message-ID
<m3wsjos9jm.fsf@localhost.localdomain>
In-Reply-To
<9f01c190-73b6-48b1-88d9-ed67d0945d81@k13g2000hse.googlegroups.com>
chongyc <chongyc27@gmail.com> writes:
Show 6 quoted lines
> I have found buggy commit object which I had committed into  git
> repository  wrongly
> 
> So I am going to delete it from my git repository
> 
> How to do it ?

If it is just created commit (and not yet published), use "git commit --amend" to correct it, or "git reset --hard HEAD^" to just drop it.

If you have published history (somebody is relying on history containing broken commit) the only way is to add commit reverting changes brought by broken commit using git-revert.

If you can rewrite history, use "git rebase --interactive" and simply remove the commit from instructions/series file if the commit you want to remove is not too deep in history, or use git-filter-branch if broken commit is somewhere deeper. See documentation for details.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: chongyc
Message 2 of 2 in “I want delete fault commit from my git repository”
  1. chongycJul 14, 2008
  2. Jakub NarebskiJul 14, 2008

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.