0

I found excellent answer https://stackoverflow.com/a/4099805/4632019

I can see differences in file between branches:

$ git diff my_branch..master -- the/file.md
diff --git a/the/file.md b/the/file.md
index 986e16d..13b14d3 100644
--- a/the/file.md
+++ b/the/file.md
@@ -11,7 +11,7 @@ In this step we are going to setup and run

 ### Create GitHub Account

-1. Create a GitHub account email on [GitHub](https://github.com)
+1. Create a GitHub account email on [GitHub](https://github.com) if you don't already have one.
 2. Generate a personal access token (classic) [here](https://docs.github.com/en/authentication/keeping-your-account-an>

 Note: After setting up repositories, your username/token will be stored by system keychain. So you will not be require>
@@ -107,11 +107,11 @@ Macbook](./prepare-your-macbook.md#docker).

 First, make sure the Docker Desktop is running:

-[Docker Desktop is running](./docker-desktop-is-running.png)
+![Docker Desktop is running](./docker-desktop-is-running.png)

 Then, ensure the VM has at least 2GB of RAM:

-[Docker Desktop configuration](./docker-desktop-configuration.png)
+![Docker Desktop configuration](./docker-desktop-configuration.png)

 If using Mac with Apple silicon, use Rosetta emulation. Docker Desktop -> Settings -> Features in development -> Use r>

@@ -143,6 +143,8 @@ cd ~/dev/wi-deploy
 ./script/deploy-local.sh

+NOTICE: If something goes wrong and you want to redeploy your containers with new arguments, then use `--force` flag.
+
 ### Start Front-End HTTP Proxy

But when I tried to see changes from my branch: git diff my_branch...master -- the/file.md

I see whole commit from my branch:

diff --git a/the/file.md b/the/file.md
index 2ee0878..986e16d 100644
--- a/the/file.md
+++ b/the/file.md
@@ -9,6 +9,13 @@ In this step we are going to setup and run

 ## Setup Projects

+### Create GitHub Account
+
+1. Create a GitHub account email on [GitHub](https://github.com)
+2. Generate a personal access token (classic) [here](https://docs.github.com/en/authentication/keeping-your-account-an>
+
+Note: After setting up repositories, your username/token will be stored by system keychain. So you will not be require>
+
 There are 3 main git repositories:
 - [PlanitarInc/wi-api](https://github.com/PlanitarInc/wi-api)
   contains the back-end code.

But I want to see only actual changes. Like on first command, but without second and third patch, eg. ignore my changes, which are already on master:

--- a/the/file.md
+++ b/the/file.md
@@ -11,7 +11,7 @@ In this step we are going to setup and run

 ### Create GitHub Account

-1. Create a GitHub account email on [GitHub](https://github.com)
+1. Create a GitHub account email on [GitHub](https://github.com) if you don't already have one.
 2. Generate a personal access token (classic) [here](https://docs.github.com/en/authentication/keeping-your-account-an>

 Note: After setting up repositories, your username/token will be stored by system keychain. So you will not be require>

Is there a command to see such changes?

Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
  • @mkrieger1: the full output of this command your can see at my question. Did you do mistake at your question? – Eugen Konkov Jul 29 '23 at 16:26
  • Does this answer your question? [Is there a quick way to "git diff" from the point or branch origin?](https://stackoverflow.com/questions/29810331/is-there-a-quick-way-to-git-diff-from-the-point-or-branch-origin) – mkrieger1 Jul 29 '23 at 17:13
  • @mkrieger1: No, that does not answer my question. – Eugen Konkov Jul 31 '23 at 13:25
  • Why not? As far as I can understand, you want to show the difference from the common ancestor of two branches to the tip of one of the branches, for one file. – mkrieger1 Jul 31 '23 at 14:43
  • @mkrieger1: I want to see difference between two points, but without patches already implemented on both points. Please read about the expected result described above and my comment under the answer below. – Eugen Konkov Jul 31 '23 at 14:58

1 Answers1

0

I don't entirely get the details of your question, but it looks like you would like git diff to compare your file to a version which doesn't exist in git.

git diff can only compare two versions of a file that are stored in your repo, it will not create a virtual version which would include some patches and exclude others.

You will need to actually create the starting version you would like to compare to.

Perhaps it already exists, as part of an intermediate commit: check git log --oneline --graph master to see if some commit already includes the patches you want to overlook, and compare to that commit.

Otherwise, use the standard commands (git cherry-pick or git rebase -i mostly) to create the version you are looking for.

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • Both versions are available to git. I have same file on two branches. This file was changed on master branch and on my branch too. These changes are intersecting a bit. If I do `diff` for `my_branch...master` I see whole patch I did on my branch. But I want to see them minus similar changes on master branch. Like `my_branch..master` (two points) comparison shows, but without `@@ -107,11 +107,11 @@` and `@@ -143,6 +143,8 @@` patches, because they were made on master branch and without `+2 ...`, `+Note` lines, because they are same changes. – Eugen Konkov Jul 29 '23 at 16:32
  • If I understand correctly, the version "like two points comparison, but without x and y patches and without ..." isn't in git. – LeGEC Jul 29 '23 at 19:31
  • Also, if you want to see the changes on `my_branch` side, you would need to switch the order : `git diff master...my_branch` (but it looks like this isn't what you are looking for) – LeGEC Jul 29 '23 at 19:34