Home > Enterprise >  Git : detecting only missing parts, not those who have just moved
Git : detecting only missing parts, not those who have just moved

Time:11-15

I'm editing a markdown file, I'm using for learning.
It has the content:

AB
CDE
EFG
IJK
LM

At a time, I was unhappy with my understandings and redistributed my paragraphs and text differently to change the plan

CDE
AB
EG
LM

After having done that, I'm fearing: with all these cut-paste, didn't I lose some text?

Is there a way to make Git compare files, but ask it not to report moved blocks?
Displaying only blocks added to or deleted from somewhere
without being deleted from or added to somewhere else.

I'm searching options in the Git command that would:

  • detect that the line IJK is entirely missing,
    (ideally, detect that the F part is now missing in the line EFG)
  • but wouldn't report that AB and CDE have moved.

CodePudding user response:

By committing the changes, Git will save a new version of the changed file not only changing data. to be concise git stores snapshots, not differences. (read this for more information)

When an application wants to create a diff log, based on the history of git, it will compare these two versions and create a display.

So how does an application display difference between two commits, it totally depends on the application and has nothing to do with how the git saves the data.

CodePudding user response:

Git itself, internally, uses an algorithm1 in which each original line of text is turned into a single "symbol". You can think of these as roughly similar to using a symbol for an entire word, such as replacing the word "clock" with an emoji:

  •  Tags:  
  • git
  • Related