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

Force Confirmation for Dropping Changed Lines

From
HWHilco Wijbenga <hilco.wijbenga@gmail.com>
Date
Jan 25, 2017, 22:16 UTC
Message-ID
<CAE1pOi2YZayEfKxxh3gsTds1mQ9L1E9AW=wPnmW=Dg=-EMj=tw@mail.gmail.com>
Hi all,

Most of the time, when a later commit changes a line in an identical fashion during, say, a rebase, you want Git to silently continue by dropping the duplicate change from the later commit. I have a common (for me) scenario where I want Git to specifically ask me to resolve this "conflict" myself instead of simply assuming that the change has already been applied.

Let's say I have a file my-code.x that starts with a line indicating its version:

===== my-code.x ===== VERSION=1.2 line 1 line 2 line 3 =====

In my branch my-branch off of master, I make a change:

===== my-code.x ===== VERSION=1.3 line 1 line 2 line 2a line 3 =====

Now someone else makes a different change on master and pushes it ([1]):

===== my-code.x ===== VERSION=1.3 line 1 line 2 line 3 line 4 =====

When I rebase my-branch onto origin/master, I get no conflicts and everything seems fine ([2]):

===== my-code.x ===== VERSION=1.3 line 1 line 2 line 2a line 3 line 4 =====

Except that I should have used VERSION=1.4, not VERSION=1.3 because I made a change to my-code.x. Obviously, for a single file this is easy to remember/check but when it's hidden among lots of files and commits it becomes very hard to find these types of errors.

How can I force Git to not assume my change to the first line is "redundant"?

Cheers, Hilco

[1] Note that this someone is (correctly) using the same, new version of 1.3. [2] If my example is actually incorrect, then please just pretend there are no conflicts.

Next: Jacob Keller
Message 1 of 11 in “Force Confirmation for Dropping Changed Lines”
  1. Hilco WijbengaJan 25, 2017
  2. Jacob KellerJan 25, 2017
  3. Hilco WijbengaJan 25, 2017
  4. Jacob KellerJan 25, 2017
  5. Junio C HamanoJan 25, 2017
  6. Hilco WijbengaJan 25, 2017
  7. Jacob KellerJan 26, 2017
  8. Junio C HamanoJan 26, 2017
  9. Jacob KellerJan 26, 2017
  10. Hilco WijbengaJan 26, 2017
  11. Junio C HamanoJan 26, 2017

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.