4

I have some img and Illustrator files in my repo but I would like to see all the changes made in my last commit (in the files that contain code only). I run:

git show HEAD

But then, after reviewing a few files, I get this (image below). My question is... how do you skip something like that? This is probably one of the large Illustrator/JPGS file. I would like to go past it and look up the rest of files that contains something with an actual meaning.

I am using git bash console - just so you know.

I know that most of you would say that I should not put large files in the repository in the first place... and you are probably right, but this would not answer my question.

Holding down ENTER for ages and watching screen go green would probably not be the ultimate solution either.

enter image description here

Antoine
  • 800
  • 3
  • 14
  • 29
DevWL
  • 17,345
  • 6
  • 90
  • 86

2 Answers2

3

Try this out:

git show --pretty="format:" --name-only HEAD

It should print the list of files in your last commit.


Filter specific types

git diff -- '*.jpg' '*.png'

The quotes are important, list all your required ignored files and it will cont display them


Another option:

git log --cc

enter image description here


As best practice

you should not add binary files to git.
You have other solution for such a case when you need to add binaries use github LFS for example, git attributes and so on,

Git doesn't treat well binary files so try to avoid it.

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • This is not exacly what I am after. I would like to show all files in one go perhaps there Is a way to show all repo excluding files with .jpg, .pdf. ia extension ? – DevWL Jan 07 '16 at 01:48
  • 1
    you will have to do with a script that flirt those results. somethig like `git diff -- '*.jpg' '*.png'` – CodeWizard Jan 07 '16 at 01:50
  • thanks filtring diff would prabobly do the job. I will also give a try to github LFS. – DevWL Jan 07 '16 at 01:54
  • You ment something like this: git diff HEAD^ HEAD -- "*.php" "*.yml". I don't think that there is a way to exclude file extension such as .pdf or .ia because "!.*pdf" simple won't work. – DevWL Jan 07 '16 at 02:32
3

You probably want to force Git to treat those files as binaries by using Git attributes. Put something like this in your .gitattributes file (create it if it doesn't exist):

*.myext binary

See the following post: How do I make Git treat a file as binary?

Community
  • 1
  • 1
kfunk
  • 2,002
  • 17
  • 25