{"id":160,"date":"2019-07-25T18:04:29","date_gmt":"2019-07-25T18:04:29","guid":{"rendered":"https:\/\/openapex.org\/spaces\/software\/?p=160"},"modified":"2022-02-18T18:23:55","modified_gmt":"2022-02-18T12:53:55","slug":"git-globally-ignore-certain-file-types","status":"publish","type":"post","link":"https:\/\/mutesoft.com\/spaces\/software\/git-globally-ignore-certain-file-types.html","title":{"rendered":"Git &#8211; Globally Ignore Certain File Types"},"content":{"rendered":"\n<p>If you do not wish to store certain files or files types in your <code>Git<\/code> repository, ignore them by adding the file name patterns to the <code>.gitignore<\/code> file.  You may add multiple <code>.gitignore<\/code> files in a repository. One at the root directory of the repository and one or more at subdirectories to apply distinct patterns specific to those subdirectories. Once you check-in <code>.gitignore<\/code> file, all the developers working on that repository will get the same effect. This is standard practice. <\/p>\n\n\n\n<p>However, if you work on multiple repositories and you want to apply similar ignore rules to multiple repositories, there are two options:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Copy the <code>.gitignore<\/code> file to all the repositories<\/li><li>Use a global <code>.gitignore<\/code> file<\/li><\/ol>\n\n\n\n<p>In this article, I&#8217;ll show you the steps to use a global <code>.gitignore<\/code> file to apply the exclusion pattern to all your repositories. Create a new file named <code>.gitignore-global<\/code> (or any other name you like) at the user&#8217;s home directory or any other directory of your choice. Add all required exclusions to this file just like a normal<code>.gitignore<\/code> file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"atomic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Create a new file named .gitignore-global\nvi ~\/.gitignore-global<\/pre>\n\n\n\n<p>The below exclusion patterns are just a sample.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"ini\" data-enlighter-theme=\"atomic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Package Files\n*.jar\n *.war\n *.nar\n *.ear\n *.zip\n *.tar.gz\n *.rar.settings\n .project\n .classpath\n# Eclipse Files\n.settings\n .project\n .classpath\n# Mac Files\n.DS_Store\n.DS_Store?<\/pre>\n\n\n\n<p>Now, change the <code>Git<\/code> configuration to apply the above-created exclusions globally.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"atomic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Apply global gitignore by supplying the path to the global gitognore file\ngit config --global core.excludesfile ~\/.gitignore-global<\/pre>\n\n\n\n<p>When the <code>.gitignore<\/code> file is checked into the Git repository, all collaborators get the exclusion list automatically when they clone the repository or pull the latest code. In case you use a global ignore list, every collaborator has to configure the global ignore list individually. This is a downside. I recommend continuing with the conventional way of having a <code>.gitignore<\/code> file in the repository and also having a global ignore list to avoid the hassle of defining the same ignore list in every repository you work on.<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ll show you the steps to use a global .gitignore file to apply the exclusion pattern to all your repositories. Create a new file named .gitignore-global (or any other name you like) at the user&#8217;s home directory or any other directory of your choice. Add all required exclusions to this file just like a normal.gitignore file.<\/p>\n","protected":false},"author":2,"featured_media":128,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"ll show you the steps to use a global .gitignore file to apply the exclusion pattern to all your repositories. Create a new file named .gitignore-global (or any other name you like) at the user&#039;s home directory or any other directory of your choice. Add all required exclusions to this file just like a normal.gitignore file.","_seopress_robots_index":"","_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[32],"tags":[31],"class_list":["post-160","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tools","tag-git"],"_links":{"self":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":7,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":1071,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/160\/revisions\/1071"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media\/128"}],"wp:attachment":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}