Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to exclude commit messages from git log when printing changed files only?

I am trying to get a list of files that have changed on a branch since some date. This is what I have now:

git log --since="2022-10-13T17:40:05.232777" --name-only --pretty=format:'%f'

And that prints:

Even-more-test-files
python/tests_index/secondtestfile.txt
python/tests_index/teeeeeeeeeest.txt

More-test-files-for-git-log
python/findtest.py

Add-some-test-file
python/tests_index/testfile.txt

That’s weird. The dash separated strings like More-test-files-for-git-log are commit messages, except for some reason spaces are replaced with dashes. What I want is just this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

python/tests_index/secondtestfile.txt
python/tests_index/teeeeeeeeeest.txt
python/findtest.py
python/tests_index/testfile.txt

No commit messages. No extra newlines. Just a list of files that have changed via a commit on this branch since the date I have given.

How to fix the --pretty argument so that I get what I want?

>Solution :

--pretty=format:'%f'

The dash separated strings like More-test-files-for-git-log are commit messages, except for some reason spaces are replaced with dashes.

That’s what you asked for:

%f
    sanitized subject line, suitable for a filename

How to fix the --pretty argument so that I get what I want?

Use --pretty=format: (or --format=).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading