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

Re: How to remove a specific hunk

From
PBPeter Baumann <waste.manager@gmx.de>
Date
Oct 31, 2007, 12:00 UTC
Message-ID
<20071031120011.GI4435@xp.machine.xx>
In-Reply-To
<Pine.LNX.4.64.0710311104450.4362@racer.site>

spearce Cc'ed, because this seems like a nice feature to add to git-gui In no way should this imply that YOU have to implement this!

On Wed, Oct 31, 2007 at 11:06:18AM +0000, Johannes Schindelin wrote:
Show 28 quoted lines
> Hi,
> 
> On Wed, 31 Oct 2007, Benoit SIGOURE wrote:
> 
> > On Oct 26, 2007, at 9:20 PM, Alex Riesen wrote:
> > 
> > > Pascal Obry, Fri, Oct 26, 2007 17:10:38 +0200:
> > > > 
> > > > Before committing sometimes I want to remove a specific hunk. Say in
> > > > file a.txt I have in the diff 3 hunks, I want to revert/delete/remove
> > > > the second one. Is there a way to do that ?
> > > 
> > > Take a look at git-gui. Try right-clicking in the diff pane at the
> > > bottom.
> > 
> > This only allows you to stage a given hunk, not to remove one.  Right 
> > now I'm in a situation where I need to remove a specific hunk to compile 
> > and it's sad that git-gui doesn't provide an option so that you can 
> > right-click -> revert hunk.
> 
> You have seen that there are two different file lists, "staged changes" 
> and "unstaged changes", right?  AFAIK if you click on the file in "staged 
> changes", you can find the staged hunk and then remove it from the staged 
> area.
> 
> "Revert hunk" would not make any sense, since the hunk disappears once you 
> staged/unstaged it.
> 

On the other hand, something like this would allow you to remove bogus hunks like debug statements you want to lose, because you tested it and all works now.

Now you first have to stage all the things you want to keep, and then select "Commit->Revert Changes" in the menu to remove a hunk forever which is a little clumsy if you have many hunks and just want to remove one of them. Seems like a nice feature to add to git gui if you throw in an extra Yes-No question for the user IFF he realy wants to remove the hunk forever.

-Peter
Previous: Pascal Obry
Message 15 of 15 in “How to remove a specific hunk”
  1. Pascal ObryOct 26, 2007
  2. Andreas EricssonOct 26, 2007
  3. Pascal ObryOct 26, 2007
  4. Benoit SIGOUREOct 26, 2007
  5. Johannes SchindelinOct 26, 2007
  6. Olivier RamonatOct 26, 2007
  7. Jeff KingOct 26, 2007
  8. Jeff KingOct 26, 2007
  9. Miles BaderOct 29, 2007
  10. Alex RiesenOct 26, 2007
  11. Benoit SIGOUREOct 31, 2007
  12. Johannes SchindelinOct 31, 2007
  13. Florian WeimerOct 31, 2007
  14. Pascal ObryOct 31, 2007
  15. Peter BaumannOct 31, 2007

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.