Skip to main content
added 17 characters in body
Source Link
Git Harpon
  • 181
  • 2
  • 12

I'm using git diff to get the differences between a commit and his parent for a specific file. I'm using this command :

git diff parent-sha child-sha -- file/to/path 

Here is my problem : with this command I can get added, deleted and modified files for a specific commit. But when I try it on my current commit, I can only get modified/deleted files. I'm looking for a way to get deleted and added files for the current commit (comparing to his parent).

For instance here's my uncommitted changes : [![enter image description here][1]][1]

If I run git diff HEAD -- yarn.lock

I get this

diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index c06acb9..0000000 --- a/yarn.lock +++ /dev/null @@ -1,10383 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"7zip-bin@~4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/7zip-bin/-/7zip-bin-4.1.0.tgz#33eff662a5c39c0c2061170cc003c5120743fff0" - integrity sha512-AsnBZN3a8/JcNt+KPkGGODaA4c7l3W5+WpeKgGSbstSLxqWtTXqd1ieJGBQ8IFCtRg8DmmKUcSkIkUc0A4p3YA== - -"@angular-devkit/[email protected]": - version "0.11.4" - resolved "https://registry.yarnpkg.com/@angular-devkit/architect/-/architect-0.11.4.tgz#f0cc3b4f1dd0128f6b41d3bb760bcf4c324cd063" - integrity sha512-2zi6S9tPlk52vyqN67IvFoeNgd0uxtrPlwl3TdvJ3wrH7sYGJnkQ+EzAE7cKUGWAV989BbNtx2YxhRDHnN21Fg== 

But nothing on git diff -- src/app/models/DiffFileInformation.ts [1]: https://i.sstatic.net/VBU6U.png

I'm using git diff to get the differences between a commit and his parent for a specific file. I'm using this command :

git diff parent-sha child-sha -- file/to/path 

Here is my problem : with this command I can get added, deleted and modified files for a specific commit. But when I try it on my current commit, I can only get modified files. I'm looking for a way to get deleted and added files for the current commit (comparing to his parent).

I'm using git diff to get the differences between a commit and his parent for a specific file. I'm using this command :

git diff parent-sha child-sha -- file/to/path 

Here is my problem : with this command I can get added, deleted and modified files for a specific commit. But when I try it on my current commit, I can only get modified/deleted files. I'm looking for a way to get deleted and added files for the current commit (comparing to his parent).

For instance here's my uncommitted changes : [![enter image description here][1]][1]

If I run git diff HEAD -- yarn.lock

I get this

diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index c06acb9..0000000 --- a/yarn.lock +++ /dev/null @@ -1,10383 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"7zip-bin@~4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/7zip-bin/-/7zip-bin-4.1.0.tgz#33eff662a5c39c0c2061170cc003c5120743fff0" - integrity sha512-AsnBZN3a8/JcNt+KPkGGODaA4c7l3W5+WpeKgGSbstSLxqWtTXqd1ieJGBQ8IFCtRg8DmmKUcSkIkUc0A4p3YA== - -"@angular-devkit/[email protected]": - version "0.11.4" - resolved "https://registry.yarnpkg.com/@angular-devkit/architect/-/architect-0.11.4.tgz#f0cc3b4f1dd0128f6b41d3bb760bcf4c324cd063" - integrity sha512-2zi6S9tPlk52vyqN67IvFoeNgd0uxtrPlwl3TdvJ3wrH7sYGJnkQ+EzAE7cKUGWAV989BbNtx2YxhRDHnN21Fg== 

But nothing on git diff -- src/app/models/DiffFileInformation.ts [1]: https://i.sstatic.net/VBU6U.png

added 17 characters in body
Source Link
Git Harpon
  • 181
  • 2
  • 12

I'm using git diff to get the differences between a commit and his parent for a specific file. I'm using this command :

git diff parent-sha child-sha -- file/to/path 

Here is my problem : with this command I can get added, deleted and modified files for a specific commit. But when I try it on HEADmy current commit, I can only get modified commitfiles. I'm looking for a way to get deleted and added files for the HEADcurrent commit (comparing HEAD to his parent).

I'm using git diff to get the differences between a commit and his parent for a specific file. I'm using this command :

git diff parent-sha child-sha -- file/to/path 

Here is my problem : with this command I can get added, deleted and modified files for a specific commit. But when I try it on HEAD, I can only get modified commit. I'm looking for a way to get deleted and added files for the HEAD (comparing HEAD to his parent)

I'm using git diff to get the differences between a commit and his parent for a specific file. I'm using this command :

git diff parent-sha child-sha -- file/to/path 

Here is my problem : with this command I can get added, deleted and modified files for a specific commit. But when I try it on my current commit, I can only get modified files. I'm looking for a way to get deleted and added files for the current commit (comparing to his parent).

Source Link
Git Harpon
  • 181
  • 2
  • 12

Get added and deleted files from git diff output with HEAD

I'm using git diff to get the differences between a commit and his parent for a specific file. I'm using this command :

git diff parent-sha child-sha -- file/to/path 

Here is my problem : with this command I can get added, deleted and modified files for a specific commit. But when I try it on HEAD, I can only get modified commit. I'm looking for a way to get deleted and added files for the HEAD (comparing HEAD to his parent)