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

git diff without intermediate commits

From
SDSudheer D <sudheer.d@ibm.com>
Date
Mar 9, 2023, 05:52 UTC
Message-ID
<MN2PR15MB3454AE2CE41E79F2B260DDD3E1B59@MN2PR15MB3454.namprd15.prod.outlook.com>
Hello List,
I have a question regarding git diff command.

My Problem: When we work in git projects under github, we will normally create a local branch, make some changes commit it create a PR & send that for review may have to merge 'master' branch one or more times to make sure that automated build works properly after merging the latest master branch. Will enhance the PR based on review comments OR add new changes.

Assuming that my commit history is as follows:

a. commit1     <-- My local commit 1 b. merge_commit1 <- Merge commit from 'master' c. merge_commit2 .... f. merge_commit_n g. commit2  <-- My local commit 2

Now, if I issue 'git diff commit1 commit2', git will show a diff of commit1, commit2 plus the intermediate merge commits. What git does here is absolutely correct. But, my requirement is to only have the difference between commit1 & commit2 (without the intermediate merge commits).

We can definitely compare individual files between two commits in the following manner e.g., git diff commit1:file commit2:file but, if I want to get the diff for all my files from commit1 to commit2 without considering totally unrelated files from the merge commits in between commit1 and commit2, I think it is a tedious process. Correct me if I am wrong.

So, my questions are.
Is there a feature readily available in git that will compare just commit1 & commit2 without considering the intermediate merge commits?
 If the answer to the above question to is 'no', if I am providing a patch for the same for 'git diff' & 'git difftool' probably with a new command line option, would you accept it?

Thank You! Sudheer

Next: Jeff King
Message 1 of 3 in “git diff without intermediate commits”
  1. Sudheer DMar 9, 2023
  2. Jeff KingMar 9, 2023
  3. Junio C HamanoMar 9, 2023

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.