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

Re: Re: How to find the commit that erase a change

From
Wwuzhouhui <wuzhouhui14@mails.ucas.ac.cn>
Date
Oct 9, 2019, 03:51 UTC
Message-ID
<6cfb13f7.1fa14.16daea502c2.Coremail.wuzhouhui14@mails.ucas.ac.cn>
In-Reply-To
<xmqqmuealiy3.fsf@gitster-ct.c.googlers.com>
Show 39 quoted lines
> -----Original Messages-----
> From: "Junio C Hamano" <gitster@pobox.com>
> Sent Time: 2019-10-09 11:02:44 (Wednesday)
> To: wuzhouhui <wuzhouhui14@mails.ucas.ac.cn>
> Cc: git@vger.kernel.org, cuifang@sugon.com
> Subject: Re: How to find the commit that erase a change
> 
> wuzhouhui <wuzhouhui14@mails.ucas.ac.cn> writes:
> 
> > I have a file which contains complicated change history. When I use
> >     git log -p file
> > to see all changes made in this file, I found that a change disappeared
> > for no reason.
> 
> "git log [-p] <pathspec>" is not about seeing *all* changes made to
> the path(s) that match the pathspec.  Especially when your history
> has merges, the command is to give you _one_ simplest explanation as
> to how the contents of the path(s) came to be in the shape you see
> in HEAD.
> 
> So for example, if you have a history like this (time flows from
> left to right):
> 
>     O-----A-----B----M-----N
>            \        /
>             \      /
>              X----Y
> 
> where A or B did *not* touch "file", X added a definition of func()
> to "file", Y reverted the change X made to "file", M made a natural
> merge between B and Y and N did not touch "file", "git log N file"
> would not even show the existence of commits X or Y.  In the larger
> picture, at ancient time O, the file started without func(), and
> none of the commits A, B, M or N felt the need to add it and as the
> result, N does not need the unwanted func().  So "file's contents
> are the same since O throughout the history reaching N" is given as
> _one_ simplest explanation.
> 
> The "--full-history" option may help, though.
"--full-history" doesn't resolve my problem, but
    git log -p -c file
does. I found that my change was erased in a merge commit.
Thanks.
Previous: Junio C HamanoNext: Derrick Stolee
Message 3 of 4 in “How to find the commit that erase a change”
  1. wuzhouhuiOct 9, 2019
  2. Junio C HamanoOct 9, 2019
  3. wuzhouhuiOct 9, 2019
  4. Derrick StoleeOct 9, 2019

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.