{"id":867,"date":"2023-06-16T09:35:23","date_gmt":"2023-06-16T16:35:23","guid":{"rendered":"https:\/\/jasonflaherty.com\/blog\/?p=867"},"modified":"2023-10-17T21:21:55","modified_gmt":"2023-10-18T04:21:55","slug":"harnessing-the-power-of-gitignore-supercharging-development-in-drupal-10","status":"publish","type":"post","link":"https:\/\/jasonflaherty.com\/blog\/2023\/06\/16\/harnessing-the-power-of-gitignore-supercharging-development-in-drupal-10\/","title":{"rendered":"Harnessing the Power of .gitignore: Supercharging Development in Drupal 10"},"content":{"rendered":"\n<p>In the fast-paced world of web development, every second counts. Whether you&#8217;re working on a personal project or a large-scale Drupal 10 project, optimizing your development process is key. One often overlooked but immensely powerful tool that can help in this endeavor is the humble .gitignore file. In this blog post, we&#8217;ll explore the importance and practical use of the .gitignore file in securing and accelerating the journey from development to production releases in Drupal 10 projects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is the .gitignore file, and why does it matter?<\/h2>\n\n\n\n<p>The .gitignore file serves as a roadmap for Git, the version control system that many developers rely on. Its purpose is simple but crucial: to tell Git which files and directories it should ignore when tracking changes. By specifying files and directories to exclude, you can keep your repository clean and free from clutter, ensuring that only essential code and assets are versioned. This practice not only improves the security of your project but also helps streamline development workflows and minimize potential pitfalls during deployment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Securing your Drupal 10 project:<\/h2>\n\n\n\n<p>Security should always be a top priority in any development project, especially when working with a robust CMS like Drupal 10. The .gitignore file acts as a guardian, preventing sensitive data from being inadvertently committed to your repository. By excluding files containing sensitive information such as configuration files, credentials, and log files, you reduce the risk of exposing valuable data to unauthorized access. This simple step can save you from potential security breaches and protect your project&#8217;s integrity.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Speeding up your development cycle:<\/h2>\n\n\n\n<p>Time is of the essence, and developers are always seeking ways to optimize their workflow. The .gitignore file plays a crucial role in this regard. By excluding unnecessary files, such as temporary files, cache directories, and development-specific artifacts, you can reduce the overall size of your repository. This not only speeds up cloning and pulling operations but also minimizes the chances of accidentally including irrelevant files in your commits. With a leaner repository, you&#8217;ll experience faster synchronization, more efficient collaboration, and smoother deployments.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Best practices for Drupal 10 projects:<\/h2>\n\n\n\n<p>When working with Drupal 10, there are a few specific considerations to keep in mind when configuring your .gitignore file. Here are some recommended entries to include:<\/p>\n\n\n\n<p>1. Vendor directories: Exclude directories such as &#8220;vendor&#8221; and &#8220;node_modules&#8221; to prevent unnecessary tracking of dependencies managed by package managers like Composer and npm.<\/p>\n\n\n\n<p>2. Configuration files: Drupal stores important configuration files in the &#8220;sites\/default&#8221; directory. Ensure that files containing sensitive information, such as database connection details, are excluded from version control.<\/p>\n\n\n\n<p>3. Temporary files and directories: Drupal generates temporary files during runtime, which should be excluded. Examples include the &#8220;files&#8221; directory for uploaded files and the &#8220;temp&#8221; directory for temporary storage.<\/p>\n\n\n\n<p>4. Logs and caches: Exclude directories like &#8220;logs&#8221; and &#8220;cache&#8221; to prevent them from being added to your repository. These files are usually regenerated during deployment or can be safely ignored in version control.<\/p>\n\n\n\n<p>In the world of Drupal 10 development, the .gitignore file is a small yet powerful tool that can significantly enhance your workflow. By excluding irrelevant files, securing sensitive data, and optimizing your repository size, you can speed up your development cycle and ensure a smoother transition from development to production releases. Embrace the simplicity of the .gitignore file, and unlock the true potential of your Drupal 10 projects. Happy coding!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sample .gitignore<\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<style>.gist table { margin-bottom: 0; }<\/style><div style=\"tab-size: 8\" id=\"gist123024799\" class=\"gist\">\n    <div class=\"gist-file\" translate=\"no\" data-color-mode=\"light\" data-light-theme=\"light\">\n      <div class=\"gist-data\">\n        \n<div class=\"js-gist-file-update-container js-task-list-container\">\n      <div id=\"file-gitignore\" class=\"file my-2\">\n    \n    <div itemprop=\"text\"\n      class=\"Box-body p-0 blob-wrapper data type-ignore-list  \"\n      style=\"overflow: auto\" tabindex=\"0\" role=\"region\"\n      aria-label=\".gitignore content, created by jasonflaherty on 04:30PM on June 16, 2023.\"\n    >\n\n        \n<div class=\"js-check-hidden-unicode js-blob-code-container blob-code-content\">\n\n  <template class=\"js-file-alert-template\">\n  <div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n  <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg>\n    <span>\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.\n      <a class=\"Link--inTextBlock\" href=\"https:\/\/github.co\/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a>\n    <\/span>\n\n\n  <div data-view-component=\"true\" class=\"flash-action\">        <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\">    Show hidden characters\n<\/a>\n<\/div>\n<\/div><\/template>\n<template class=\"js-line-alert-template\">\n  <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\">\n    <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg>\n<\/span><\/template>\n\n  <table data-hpc class=\"highlight tab-size js-file-line-container\" data-tab-size=\"4\" data-paste-markdown-skip data-tagsearch-path=\".gitignore\">\n        <tr>\n          <td id=\"file-gitignore-L1\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n          <td id=\"file-gitignore-LC1\" class=\"blob-code blob-code-inner js-file-line\"># Drupal-specific files and directories to ignore# Exclude core directory<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L2\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n          <td id=\"file-gitignore-LC2\" class=\"blob-code blob-code-inner js-file-line\">\/web\/core<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L3\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n          <td id=\"file-gitignore-LC3\" class=\"blob-code blob-code-inner js-file-line\"># Exclude vendor directory<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L4\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n          <td id=\"file-gitignore-LC4\" class=\"blob-code blob-code-inner js-file-line\">\/vendor\/<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L5\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n          <td id=\"file-gitignore-LC5\" class=\"blob-code blob-code-inner js-file-line\"># Exclude Drupal settings files<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L6\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n          <td id=\"file-gitignore-LC6\" class=\"blob-code blob-code-inner js-file-line\">\/web\/sites\/*\/settings.*.php<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L7\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n          <td id=\"file-gitignore-LC7\" class=\"blob-code blob-code-inner js-file-line\"># Exclude Drupal services files<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L8\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n          <td id=\"file-gitignore-LC8\" class=\"blob-code blob-code-inner js-file-line\">\/web\/sites\/*\/services*.yml<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L9\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n          <td id=\"file-gitignore-LC9\" class=\"blob-code blob-code-inner js-file-line\"># Exclude Drupal files and private directories<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L10\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n          <td id=\"file-gitignore-LC10\" class=\"blob-code blob-code-inner js-file-line\">\/web\/sites\/*\/files<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L11\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"11\"><\/td>\n          <td id=\"file-gitignore-LC11\" class=\"blob-code blob-code-inner js-file-line\">\/web\/sites\/*\/private<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L12\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"12\"><\/td>\n          <td id=\"file-gitignore-LC12\" class=\"blob-code blob-code-inner js-file-line\"># Exclude Drupal simpletest directory<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L13\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"13\"><\/td>\n          <td id=\"file-gitignore-LC13\" class=\"blob-code blob-code-inner js-file-line\">\/web\/sites\/simpletest<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L14\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"14\"><\/td>\n          <td id=\"file-gitignore-LC14\" class=\"blob-code blob-code-inner js-file-line\"># Directories specific to this template<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L15\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"15\"><\/td>\n          <td id=\"file-gitignore-LC15\" class=\"blob-code blob-code-inner js-file-line\"># Exclude libraries directory<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L16\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"16\"><\/td>\n          <td id=\"file-gitignore-LC16\" class=\"blob-code blob-code-inner js-file-line\">#\/web\/libraries<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L17\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"17\"><\/td>\n          <td id=\"file-gitignore-LC17\" class=\"blob-code blob-code-inner js-file-line\"># Exclude contributed modules directory<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L18\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"18\"><\/td>\n          <td id=\"file-gitignore-LC18\" class=\"blob-code blob-code-inner js-file-line\">\/web\/modules\/contrib<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L19\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"19\"><\/td>\n          <td id=\"file-gitignore-LC19\" class=\"blob-code blob-code-inner js-file-line\"># Exclude contributed profiles directory<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L20\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"20\"><\/td>\n          <td id=\"file-gitignore-LC20\" class=\"blob-code blob-code-inner js-file-line\">\/web\/profiles\/contrib<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L21\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"21\"><\/td>\n          <td id=\"file-gitignore-LC21\" class=\"blob-code blob-code-inner js-file-line\"># Exclude contributed themes directory<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L22\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"22\"><\/td>\n          <td id=\"file-gitignore-LC22\" class=\"blob-code blob-code-inner js-file-line\">\/web\/themes\/contrib<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L23\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"23\"><\/td>\n          <td id=\"file-gitignore-LC23\" class=\"blob-code blob-code-inner js-file-line\"># Sass<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L24\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"24\"><\/td>\n          <td id=\"file-gitignore-LC24\" class=\"blob-code blob-code-inner js-file-line\">.sass-cache<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L25\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"25\"><\/td>\n          <td id=\"file-gitignore-LC25\" class=\"blob-code blob-code-inner js-file-line\">*.css.map<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L26\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"26\"><\/td>\n          <td id=\"file-gitignore-LC26\" class=\"blob-code blob-code-inner js-file-line\"># NPM<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L27\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"27\"><\/td>\n          <td id=\"file-gitignore-LC27\" class=\"blob-code blob-code-inner js-file-line\">npm-debug.log<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L28\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"28\"><\/td>\n          <td id=\"file-gitignore-LC28\" class=\"blob-code blob-code-inner js-file-line\">node_modules\/<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L29\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"29\"><\/td>\n          <td id=\"file-gitignore-LC29\" class=\"blob-code blob-code-inner js-file-line\"># Database backups<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L30\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"30\"><\/td>\n          <td id=\"file-gitignore-LC30\" class=\"blob-code blob-code-inner js-file-line\">*.gz<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L31\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"31\"><\/td>\n          <td id=\"file-gitignore-LC31\" class=\"blob-code blob-code-inner js-file-line\">*.sql.gz<\/td>\n        <\/tr>\n        <tr>\n          <td id=\"file-gitignore-L32\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"32\"><\/td>\n          <td id=\"file-gitignore-LC32\" class=\"blob-code blob-code-inner js-file-line\">*.sql<\/td>\n        <\/tr>\n  <\/table>\n<\/div>\n\n\n    <\/div>\n\n  <\/div>\n\n<\/div>\n\n      <\/div>\n      <div class=\"gist-meta\">\n        <a href=\"https:\/\/gist.github.com\/jasonflaherty\/542cf2e69a3c37eefd6ba2f1aef53235\/raw\/aeded7fb096b84330331f12dcf104cf48c346679\/.gitignore\" style=\"float:right\" class=\"Link--inTextBlock\">view raw<\/a>\n        <a href=\"https:\/\/gist.github.com\/jasonflaherty\/542cf2e69a3c37eefd6ba2f1aef53235#file-gitignore\" class=\"Link--inTextBlock\">\n          .gitignore\n        <\/a>\n        hosted with &#10084; by <a class=\"Link--inTextBlock\" href=\"https:\/\/github.com\">GitHub<\/a>\n      <\/div>\n    <\/div>\n<\/div>\n\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In the fast-paced world of web development, every second counts. Whether you&#8217;re working on a personal project or a large-scale Drupal 10 project, optimizing your development process is key. One often overlooked but immensely powerful tool that can help in this endeavor is the humble .gitignore file. In this blog post, we&#8217;ll explore the importance and practical use of the .gitignore file in securing and accelerating the journey from development to production releases in Drupal 10 projects.<\/p>\n<p class=\"excerpt-link\"><a href=\"https:\/\/jasonflaherty.com\/blog\/2023\/06\/16\/harnessing-the-power-of-gitignore-supercharging-development-in-drupal-10\/\">&sim;&nbsp;Continue Reading&nbsp;&sim;<\/a><\/p>\n","protected":false},"author":1,"featured_media":869,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false,"jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[12,157],"tags":[188,62],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/jasonflaherty.com\/blog\/wp-content\/uploads\/2023\/06\/PXL_20230612_190837787.PANO_-scaled.jpg?fit=2560%2C906&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5OfD9-dZ","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/posts\/867"}],"collection":[{"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/comments?post=867"}],"version-history":[{"count":1,"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/posts\/867\/revisions"}],"predecessor-version":[{"id":870,"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/posts\/867\/revisions\/870"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/media\/869"}],"wp:attachment":[{"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/media?parent=867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/categories?post=867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jasonflaherty.com\/blog\/wp-json\/wp\/v2\/tags?post=867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}