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

Re: Removing a commit from a local branch

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Jan 11, 2009, 22:52 UTC
Message-ID
<20090111225220.GB15533@atjola.homenet>
In-Reply-To
<a038bef50901111442y16695664y4fed7cdd9d8af27@mail.gmail.com>
On 2009.01.12 11:42:24 +1300, Chris Packham wrote:
Show 24 quoted lines
> Hi List,
> 
> I'm part of a development team using git. We use a maintainer model
> where developers send patches/pull requests to a maintainer who
> applies the patches to a local branch, decides if they're good or not
> and pushes the good patches to the public repository.
> 
> What I want to do is script the removal of a bad patch so that the
> maintainer identifies a patch in his local branch, sends an email to
> the author telling them why their patch is being rejected then removes
> the commit for that patch. Using git log a script can extract the
> author email address, hash and headline of each commit. Based on that
> information scripting the email is easy enough. Now I come to using
> git rebase to remove the bad commit based on its hash which leads me
> to my question - How do I refer to a commit based on the hash of its
> parent?
> 
> Consider the following example. The maintainer has the following branch locally
> 
>   todeliver: A-B-C-D
> 
> He is happy with commits A, C and D but wants to reject B. Ideally I
> want to be able to say
>   git rebase --onto <parent of B> <child of B> todelvier
You don't want <child of B> there, just B.
git rebase --onto <onto> <upstream> <branch>

Rebases the commits from the range <upstream>..<branch>, and that _excludes_ the commit (referenced by) <upstream>.

So: git rebase --onto B^ B todeliver

Works on: B..todeliver == todeliver --not B And that range contains commits C and D.

Björn
Previous: Jakub NarebskiNext: Chris Packham
Message 3 of 5 in “Removing a commit from a local branch”
  1. Chris PackhamJan 11, 2009
  2. Jakub NarebskiJan 11, 2009
  3. Björn SteinbrinkJan 11, 2009
  4. Chris PackhamJan 12, 2009
  5. Sitaram ChamartyJan 12, 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.