Ignore files in git log -p

I am trying to summarize my work on the project. The problem is that I do not want to include test files in the output of git log --patch .

Files are in the same directory as mtest ; however, this folder also contains the test case code that I want to show. The test files I want to exclude have the extension mscx or xml , so I want the filter to work on it.

I looked at Executing 'git log' to ignore changes for specific paths , but it looks like it excludes commits that modified the file instead of just excluding the file.

Is there any way to do this?

I tried to answer Jubobs, and it seemed to work, but it is surprising that 2 files came up even with a filter.

I reproduced this using this small repository:

 mkdir test cd test git init echo 'readme' > README git add . git commit -m "Initial commit" mkdir test2 cd test2 echo 't1' > test1.cpp echo 't2' > test2.xml git add . git commit -m "c2" echo 't3' > test3.cpp echo 't4' > test4.xml git add . git commit -m "c3" 

I noticed that the files are not filtered when creating the directory. I tried the following commands:

 git log --patch -- . ":(exclude)**/*.xml" 

as a result, both xml files were added.

 git log --patch -- . ":(exclude)*.xml" 

This surprisingly filters out test4.xml , but not test2.xml .

+4
git git-log
source share
1 answer

I don't know which version of Git you are using /, but the issue you are reporting seems to be fixed in Git 1.9.5 (see this for more details on the fix). Next command

 git log --patch -- . ":(exclude)*.xml" 

does what you want in your toy example: as you can see below, all *.xml filtered out as desired.

 $ mkdir test $ cd test $ git init Initialized empty Git repository in /Users/jubobs/Desktop/test/.git/ $ echo 'readme' > README $ git add . $ git commit -m "initial commit" [master (root-commit) ad6cc73] initial commit 1 file changed, 1 insertion(+) create mode 100644 README $ mkdir test2 $ cd test2 $ echo 't1' > test1.cpp $ echo 't2' > test2.xml $ git add . $ git commit -m "c2" [master 8d733a2] c2 2 files changed, 2 insertions(+) create mode 100644 test2/test1.cpp create mode 100644 test2/test2.xml $ echo 't3' > test3.cpp $ echo 't4' > test4.xml $ git add . $ git commit -m "c3" [master 3e8a3f6] c3 2 files changed, 2 insertions(+) create mode 100644 test2/test3.cpp create mode 100644 test2/test4.xml $ git log --patch -- . ":(exclude)*.xml" commit 3e8a3f6c627576e8f7d1863b92d4f631ae309417 Author: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx Date: Sat Dec 27 00:19:56 2014 +0100 c3 diff --git a/test2/test3.cpp b/test2/test3.cpp new file mode 100644 index 0000000..6d6ea65 --- /dev/null +++ b/test2/test3.cpp @@ -0,0 +1 @@ +t3 commit 8d733a27a0e2c9f4c71e7b64742107255035d6cd Author: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx Date: Sat Dec 27 00:19:33 2014 +0100 c2 diff --git a/test2/test1.cpp b/test2/test1.cpp new file mode 100644 index 0000000..795ea43 --- /dev/null +++ b/test2/test1.cpp @@ -0,0 +1 @@ +t1 
+6
source share

All Articles