Rectangle 27 11

The only way to exclude files from the code coverage report is to use ...

--filter is used to filter the tests that are execute in the current run of phpunit.

--filter MyTestClass
--filter testStuffThatBrokeAndIOnlyWantToRunThatOneSingleTest

The --filter has nothing to do with the <filter> in the xml configuration even so they have the same name :)

If you use whitelist on your own source folder that should do the job in most of the cases.

<filter>
    <whitelist addUncoveredFilesFromWhitelist="true">
      <directory suffix=".php">src</directory>
    </whitelist>
  </filter>

For better or worse, phpunit.xml is becoming the only real method for handling test groupings.

This answer is all about how to include directories (whitelist), but how would you exclude directories? The opposite (blacklist) does not work.

both absolute and relative paths work for the <filter> directives. there's also a <blacklist> available if that's more your style.

unit testing - PHPUnit - exclude some directories from code coverage i...

unit-testing phpunit code-coverage xdebug
Rectangle 27 97

You can exclude folders and files by adding ExcludeFilesFromDeployment and ExcludeFoldersFromDeployment elements to your project file (.csproj, .vbproj, etc).

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 
  ... 
  <ExcludeFilesFromDeployment>File1.aspx;Folder2\File2.aspx</ExcludeFilesFromDeployment> 
  <ExcludeFilesFromDeployment>**\.svn\**\*.*</ExcludeFilesFromDeployment>
  <ExcludeFoldersFromDeployment>Folder1;Folder2\Folder2a</ExcludeFoldersFromDeployment> 
</PropertyGroup>

Is there a way to user wildcards with this?

This is much better than the accepted answer for me as I want to exclude the Web.config file during Publish!

On "Web Site" type projects, this code snippet gets added to the *.pubxml files located in ~/App_Data/PublishProfiles/.

In a web application you can add these elements to the PropertyGroup of you publish profile @ ~\Properties\PublishProfiles

Is there any way to do this via the UI rather than editing the project file directly?

Exclude files from web site publish in Visual Studio - Stack Overflow

visual-studio visual-studio-2005 web-publishing
Rectangle 27 491

After editing .gitignore to match the ignored files, you can do git ls-files -ci --exclude-standard to see the files that are included in the exclude lists; you can then do git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached to remove them from the repository (without deleting them from disk).

Edit: You can also add this as an alias in your .gitconfig file so you can run it anytime you like. Just add the following line under the [alias] section:

apply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
apply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0r git rm --cached

(The -r flag in xargs prevents git rm from running on an empty result and printing out its usage message, but may only be supported by GNU findutils. Other versions of xargs may or may not have a similar option.)

Now you can just type git apply-gitignore in your repo, and it'll do the work for you!

Brilliant and simple. This should be upvoted a thousand times and then accepted as the new correct answer.

alias apply-gitignore="git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached"
for /F "tokens=*" %a in ('git ls-files -ci --exclude-standard') do @git rm --cached "%a"

This is by far the easiest and best solution for the problem! Thanks so much!

Simple but brilliant. Thanks a lot for sharing this!

For mac users, -r is default and is not accepted by BSD versions. So remove -r.

git - Applying .gitignore to committed files - Stack Overflow

git
Rectangle 27 477

After editing .gitignore to match the ignored files, you can do git ls-files -ci --exclude-standard to see the files that are included in the exclude lists; you can then do git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached to remove them from the repository (without deleting them from disk).

Edit: You can also add this as an alias in your .gitconfig file so you can run it anytime you like. Just add the following line under the [alias] section:

apply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached

(The -r flag in xargs prevents git rm from running on an empty result and printing out its usage message, but may only be supported by GNU findutils. Other versions of xargs may or may not have a similar option.)

Now you can just type git apply-gitignore in your repo, and it'll do the work for you!

Brilliant and simple. This should be upvoted a thousand times and then accepted as the new correct answer.

alias apply-gitignore="git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached"
for /F "tokens=*" %a in ('git ls-files -ci --exclude-standard') do @git rm --cached "%a"

This is by far the easiest and best solution for the problem! Thanks so much!

For mac users, -r is default and is not accepted by BSD versions. So remove -r.

git - Applying .gitignore to committed files - Stack Overflow

git
Rectangle 27 474

After editing .gitignore to match the ignored files, you can do git ls-files -ci --exclude-standard to see the files that are included in the exclude lists; you can then do git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached to remove them from the repository (without deleting them from disk).

Edit: You can also add this as an alias in your .gitconfig file so you can run it anytime you like. Just add the following line under the [alias] section:

apply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached

(The -r flag in xargs prevents git rm from running on an empty result and printing out its usage message, but may only be supported by GNU findutils. Other versions of xargs may or may not have a similar option.)

Now you can just type git apply-gitignore in your repo, and it'll do the work for you!

Brilliant and simple. This should be upvoted a thousand times and then accepted as the new correct answer.

alias apply-gitignore="git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached"
for /F "tokens=*" %a in ('git ls-files -ci --exclude-standard') do @git rm --cached "%a"

This is by far the easiest and best solution for the problem! Thanks so much!

For mac users, -r is default and is not accepted by BSD versions. So remove -r.

git - Applying .gitignore to committed files - Stack Overflow

git
Rectangle 27 54

This may seem backwards, but you can pass a list of files not matching your exclude pattern to git grep like this:

git grep <pattern> -- `git ls-files | grep -v <exclude-pattern>`
grep -v
<exclude-pattern>
git ls-files
--exclude

Thanks for this! Git grep is so much faster than ack & co but not being able to exclude arbitrary paths was a bit too inconvenient so to speak :)

Unfortunately my repo has a lot of files. When I try @kynan's approach I get: "-bash: /usr/bin/git: Argument list too long"

This should solve both the "Argument list too long" problem of Benissimo and my problem with filename caracters interpreted by bash (like []) or filenames containing spaces in the repository: git ls-files | grep -v <exclue-pattern> | xargs -d '\n' git grep <pattern> --

Check onlynone's answer, it's possibly to do this entirely within (modern versions of) git now.

How to exclude certain directories/files from git grep search - Stack ...

git grep
Rectangle 27 53

This may seem backwards, but you can pass a list of files not matching your exclude pattern to git grep like this:

git grep <pattern> -- `git ls-files | grep -v <exclude-pattern>`
grep -v
<exclude-pattern>
git ls-files
--exclude

Thanks for this! Git grep is so much faster than ack & co but not being able to exclude arbitrary paths was a bit too inconvenient so to speak :)

Unfortunately my repo has a lot of files. When I try @kynan's approach I get: "-bash: /usr/bin/git: Argument list too long"

This should solve both the "Argument list too long" problem of Benissimo and my problem with filename caracters interpreted by bash (like []) or filenames containing spaces in the repository: git ls-files | grep -v <exclue-pattern> | xargs -d '\n' git grep <pattern> --

Check onlynone's answer, it's possibly to do this entirely within (modern versions of) git now.

How to exclude certain directories/files from git grep search - Stack ...

git grep
Rectangle 27 59

The advantage of .gitignore is that it can be checked into the repository itself, unlike .git/info/exclude. Another advantage is that you can have multiple .gitignore files, one inside each directory/subdirectory for directory specific ignore rules, unlike .git/info/exclude.

So, .gitignore is available across all clones of the repository. Therefore, in large teams all people are ignoring the same kind of files Example *.db, *.log. And you can have more specific ignore rules because of multiple .gitignore.

.git/info/exclude is available for individual clones only, hence what one person ignores in his clone is not available in some other person's clone. For example, if someone uses Eclipse for development it may make sense for that developer to add .build folder to .git/info/exclude because other devs may not be using Eclipse.

In general, files/ignore rules that have to be universally ignored should go in .gitignore, and otherwise files that you want to ignore only on your local clone should go into .git/info/exclude

When would you use .git/info/exclude instead of .gitignore to exclude ...

git gitignore
Rectangle 27 1132

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.

The .git/info/exclude file has the same format as any .gitignore file. Another option is to set core.excludesFile to the name of a file containing global patterns.

Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:

git update-index --assume-unchanged [<file>...]

Note on $GIT_DIR: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.

As a note, make sure to run git update-index --assume-unchanged [<file>...] after making the addition to the exclude file. The changes won't be picked up until then.

I did not need to run 'git update-index ...' for the changes to take effect using git 1.7.9.5.

You only need to use git update-index if you've already made a change to the file and now want it to be ignored. If you change exclude prior to making the change, it's not necessary.

While this stops the file from appearing as changed during commits like .gitignore, unlike ignored files, the file(s) will still be reset back to the repo version if you execute git reset --hard.

skip-worktree
assume-unchanged

How do I configure git to ignore some files locally? - Stack Overflow

git ignore gitignore
Rectangle 27 1132

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.

The .git/info/exclude file has the same format as any .gitignore file. Another option is to set core.excludesFile to the name of a file containing global patterns.

Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:

git update-index --assume-unchanged [<file>...]

Note on $GIT_DIR: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.

As a note, make sure to run git update-index --assume-unchanged [<file>...] after making the addition to the exclude file. The changes won't be picked up until then.

I did not need to run 'git update-index ...' for the changes to take effect using git 1.7.9.5.

You only need to use git update-index if you've already made a change to the file and now want it to be ignored. If you change exclude prior to making the change, it's not necessary.

While this stops the file from appearing as changed during commits like .gitignore, unlike ignored files, the file(s) will still be reset back to the repo version if you execute git reset --hard.

skip-worktree
assume-unchanged

How do I configure git to ignore some files locally? - Stack Overflow

git ignore gitignore
Rectangle 27 1097

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.

The .git/info/exclude file has the same format as any .gitignore file. Another option is to set core.excludesFile to the name of a file containing global patterns.

Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:

git update-index --assume-unchanged [<file>...]

Note on $GIT_DIR: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.

As a note, make sure to run git update-index --assume-unchanged [<file>...] after making the addition to the exclude file. The changes won't be picked up until then.

I did not need to run 'git update-index ...' for the changes to take effect using git 1.7.9.5.

You only need to use git update-index if you've already made a change to the file and now want it to be ignored. If you change exclude prior to making the change, it's not necessary.

While this stops the file from appearing as changed during commits like .gitignore, unlike ignored files, the file(s) will still be reset back to the repo version if you execute git reset --hard.

skip-worktree
assume-unchanged

How do I configure git to ignore some files locally? - Stack Overflow

git ignore gitignore
Rectangle 27 1090

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.

The .git/info/exclude file has the same format as any .gitignore file. Another option is to set core.excludesFile to the name of a file containing global patterns.

Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:

git update-index --assume-unchanged [<file>...]

Note on $GIT_DIR: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.

As a note, make sure to run git update-index --assume-unchanged [<file>...] after making the addition to the exclude file. The changes won't be picked up until then.

I did not need to run 'git update-index ...' for the changes to take effect using git 1.7.9.5.

You only need to use git update-index if you've already made a change to the file and now want it to be ignored. If you change exclude prior to making the change, it's not necessary.

While this stops the file from appearing as changed during commits like .gitignore, unlike ignored files, the file(s) will still be reset back to the repo version if you execute git reset --hard.

skip-worktree
assume-unchanged

How do I configure git to ignore some files locally? - Stack Overflow

git ignore gitignore
Rectangle 27 34

carej is right. I've been trying to do this, merging other jars into my application jar excluding some files, and there is no way to use <zipgroupfileset> for it.

My solution is a variant of the unzip/clean-up/jar method: I first merge all the external library jars into one with <zipgroupfileset>, then merge it into mine with <zipfileset> which does allow filtering. In my case it works noticeably faster and is cleaner than unzipping the files to disk:

<jar jarfile="${dist}/lib/external-libs.jar">
  <zipgroupfileset dir="lib/">
    <include name="**/*.jar"/>
  </zipgroupfileset>
</jar>
<sleep seconds="1"/>
<jar jarfile="${dist}/lib/historadar-${DSTAMP}.jar" manifest="Manifest.txt">
  <fileset dir="${build}" includes="**/*.*"/>
  <zipfileset src="${dist}/lib/external-libs.jar">
    <exclude name="*"/>
  </zipfileset>
</jar>

The first <jar> puts all the jars it finds in lib/ into external-libs.jar, then I make it wait for one second to avoid getting warnings about the files having modification dates in the future, then I merge my class files from the build/ directory with the content of external-libs.jar excluding the files in its root, which in this case were README files and examples.

Then I have my own README file that lists all information needed about those libraries I include in my application, such as license, website, etc.

Ant: Exclude files from merged jar file - Stack Overflow

ant jar
Rectangle 27 19

If you want to have a language-agnostic code repository the question is less about which files to exclude that about which files to include. Meaning, in a language-agnostic repo there should really only be the files necessary for the project:

You should certainly exclude:

  • .project - this is project specific config by eclipse
  • .settings folder - this is project specific config by eclipse

In Eclipse there is a 'global' ignore list for files which are shared to repositories via SVN, CVS, etc. You can find it here:

Window > Preferences > Team > Ignored Resources

If you're looking for something outside Eclipse, try the global-ignores config in your local subversion config. Add this to your ~/.subversion/config file.

global-ignores = build *.mode* *.pbxuser *~.nib .DS_Store *~

Mind that if excluding the Eclipse config from the repos you'll have to set up your projects after a checkout more specifically.

However, as you say you're using Maven this should not pose too many problems for you actually. If the pom.xml files of maven projects are configured correctly and completely, you can easily import a project from SVN via 'Import as Maven Project' - Eclipse will do all the right config for you on the import. (For this you need the m2Eclipse Maven Plugin, but I guess you'll be using something like that already? Anyway, here's the link: http://m2eclipse.sonatype.org/sites/m2e )

As for your question concerning a script to clean the repo: I'm not aware of such a thing right now, and I'd be very careful with this. Sounds like a lotta things could go horribly wrong. ;)

Last but not least, restoring the workspace: In my experience, it is often the easiest thing to just delete your project locally and to a fresh checkout 'as maven project'. This way Eclipse will reconfigure all the important stuff. I have spent hours on broken Eclipse config, sometimes it tends to just get stuck and fails to be able to recover - especially if you're working with a lot of plugins which tend to do some of their own configuration magic. (And happen to be not exactly bug free...)

java - which eclipse files to exclude from subversion repo - Stack Ove...

java eclipse svn maven ignore
Rectangle 27 26

Adds any file with a question mark next to it, while still excluding ignored files:

svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
svn commit

Hello James. Sorry I downvoted your answer, but it's a mistake. Please edit it, so I can rollback this downvote (and this comment as well).

I'm not sure why, but I beleive your regex doesn't care about filenames that contains spaces...

svn - Add all unversioned files to Subversion using one Linux command ...

svn
Rectangle 27 26

Adds any file with a question mark next to it, while still excluding ignored files:

svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
svn commit

Hello James. Sorry I downvoted your answer, but it's a mistake. Please edit it, so I can rollback this downvote (and this comment as well).

I'm not sure why, but I beleive your regex doesn't care about filenames that contains spaces...

svn - Add all unversioned files to Subversion using one Linux command ...

svn
Rectangle 27 20

Files that are "yours", files that no one else sees, write in .git/info/exclude.

For files that everyone else sees, write them down in .gitignore at the project top directory and then add and commit the .gitignore file.

*.o
.*.sw[op]
*~

Files that are local to your setup; for instance you may have a utility script in your working tree that is not tracked by git and only you can see.

version control - git untracked files - how to ignore/delete - Stack O...

git version-control dvcs gitignore git-status
Rectangle 27 68

Actually, I came here with the same question as the creator of the topic, but none of the solutions given were a complete answer to my problem. Why adding a code to ALL the files on your server when you could simply configure it once ? The closest one was Residuum's one, but still, he was excluding ALL files, when I wanted to exclude only php files that weren't named index.php.

<Files *.php>
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Files>

<Files index.php>
    Order Allow,Deny
    Allow from all
</Files>

(Remember, htaccess files are working recursively, so it suits perfectly the prerequisite of the question.)

And here we go. The only php files that will be accessible for an user will be the ones named index.php. But you can still acces to every image, css stylesheet, js script, etc.

.htaccess - Deny direct access to all .php files except index.php - St...

php .htaccess
Rectangle 27 12

Double check your .gitignore file to make sure that the file is able to be seen by Git. Likewise, there is a file .git/info/exclude that 'excludes' files/directories from the project, just like a .gitignore file would.

I'd also add to double check that the files aren't somehow "already added" or not...

Git - Won't add files? - Stack Overflow

git
Rectangle 27 26

git diff --cached --name-status will show a summary of what's staged, so you can easily exclude removed files, e.g.:

M       wt-status.c
D       wt-status.h

This indicates that wt-status.c was modified and wt-status.h was removed in the staging area (index). So, to check only files that weren't removed:

steve@arise:~/src/git <master>$ git diff --cached --name-status | awk '$1 != "D" { print $2 }'
wt-status.c
wt-status.h

You will have to jump through extra hoops to deal with filenames with spaces in though (-z option to git diff and some more interesting parsing)

Thanks, that's a good start. However, if I change a file without staging it, it's still displayed. I am running git version 1.7.0.1.147.g6d84b (recent custom build). Not sure if this is intended behavior.

That sounds odd. The "--cached" switch should make it only show files that have been staged: although I'm testing this with 1.6.5, it seems surprising that that would have changed... does "git diff --cached" on its own show the unstaged changes?

The example has a typo. $1 != "R" should read $1 != "D"

@igorw, I would be interested but the link is dead.

Git pre-commit hook : changed/added files - Stack Overflow

git hook pre-commit-hook pre-commit