Problem/Motivation

The example.gitignore in core root and core/assets/scaffold/files could be improved.

Specifically, updates could be used that:

  • Account for more permutations in multisite/environment specific configuration file names
  • Explicitly allow the default template files that got ignored by the new gitignore rules since it can be useful to keep those as reference
  • Do the same for gitignore setups where the gitignore is places in sites/ folder.

Steps to reproduce

  1. View the example.gitignore.
  2. It does not have very robust rules for ignoring settings and services files.

Proposed resolution

Update example.gitignore and core/assets/scaffold/files to change

sites/*/settings*.php
sites/*/services*.yml

to

sites/*/*settings*.php
sites/**/*services*.yml
!sites/*/default.settings.php
!sites/*/default.services.yml

Then, add to the section if you prefer to store your .gitignore file in the sites/ folder

with

# */*settings*.php
# !*/default.settings.php
# !sites/*/services.yml
# !*/default.services.yml

Remaining tasks

Update the example.gitignore files to better account for multisite/environment specific configurations.

View the example.gitignore in core root and core/assets/scaffold/files.

The file now has more robust but still sensible gitignore policies that cover multisite/environment specific configurations.

While there are more permutations of settings and services files that are ignored, there are also explicit allow rules for certain files that do not need to be ignored.

These rules are reflected also in the section for setups where the gitignore is in the sites/ folder.

Issue fork drupal-2381091

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mikeker’s picture

StatusFileSize
new458 bytes
mikeker’s picture

Status: Active » Needs review

Dang it... I never remember to set the status!

mikeker’s picture

Priority: Minor » Normal
StatusFileSize
new780 bytes

Looks like I, and those in #2326913: Add sites/*/*services*.yml to example.gitignore, missed that we need to make this change to the commented out section of the example gitignore file as well... Bumping to priority to normal since the current example.gitignore doesn't include anything about services.yml files if the .gitignore is located in the sites directory.

dawehner’s picture

Well, I would argue that you maybe actually want to have some of those in GIT, especially if you have production files, you want to track as well.
Excluding all of them by default is maybe a little bit too much, to be honest.

mikeker’s picture

@dawehner: Agreed -- I usually checking settings.php into the repo. But this is just an example .gitignore file and meant to be modified. Since there is no longer a .gitignore in Drupal core there is no worry about it being overwritten with each core update. The hope is that someone new to Drupal can just copy/paste the example file and not accidentally check-in potentially sensitive information. More experienced devs will modify it to suit their needs.

This also treats local.settings.php the same as settings.local.php. Previously only settings.local.php was ignored.

dawehner’s picture

Maybe we could explicit allow example.*services*.yml and example.*settings*.yml which itself is an example what you want to have in your repo?

mikeker’s picture

StatusFileSize
new703 bytes

Reroll after #1975220: Allow a Composer user to manage Drupal, modules, and PHP dependencies with a custom root composer.json.

re: #6: we have a default.settings.php and default.services.php along with example.gitignore. I would support renaming the first two to start with example, just for consistency and the fact that neither file is actually used as a default anything. But I think that's a debate that'll be postponed until D9 (at the earliest! :)

mikeker’s picture

Issue tags: +Quick fix

Patch still applies...

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Let's get it in.

wim leers’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/example.gitignore
@@ -26,7 +26,8 @@ sites/simpletest
+# */*services*.php

s/php/yml/ … or am I mistaken?

mikeker’s picture

Status: Needs work » Needs review
StatusFileSize
new703 bytes
new362 bytes

@Wim Leers: Not mistaken, completely correct!

Fixed in the attached patch.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Lovely :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Isn't a problem with this that (for example) default.settings.php is in git?

mikeker’s picture

Isn't a problem with this that (for example) default.settings.php is in git?

Not if those files are already in the repo. The .gitignore file only ignores new files -- from the Git manpages:

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected;

So a core contributor wanting to change default.settings.php would see their change when they run git status. If we wanted to add an example.settings.php file, it would require overriding our existing .gitignore to do so, but core contributors should be comfortable doing so and, since .gitignore is not a tracked file, it would not appear in the diff.

jeanfei’s picture

StatusFileSize
new1.09 KB

I think it should be better to specify that the default.settings.php is in git.
I've add new lines in example.gitignore for this.

mikeker’s picture

Category: Bug report » Task
Issue summary: View changes

@jeanfei, agreed, specifically adding default.settings.php makes it clearer what is and is not in the repo. Thanks for the addition.

Patch still applies cleanly to HEAD. Added beta eval to the issue summary and, since this is a followup to a task, I changed issue type.

mikeker’s picture

Issue summary: View changes
joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Looks good a bit confusing based on the title which the patch addresses but doesn't but does:)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/example.gitignore
@@ -26,7 +27,9 @@ sites/simpletest
+# !*/default.settings.php
+# */*services*.yml

Let's do the same for default.services.yml as we've done for default.settings.php

mikeker’s picture

Status: Needs work » Needs review
StatusFileSize
new821 bytes
new522 bytes

Let's do the same for default.services.yml as we've done for default.settings.php

Done.

wim leers’s picture

Status: Needs review » Needs work

default.services.yml, not default.services.php.

mikeker’s picture

Status: Needs work » Needs review
StatusFileSize
new821 bytes
new580 bytes

Yikes! Sorry about that -- pre-coffee copy/pasting is dangerous... :)

Fixed.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

sasanikolic’s picture

Status: Needs review » Needs work

Did we forget development.services.yml? I have it in sites/development.services.yml... or should I move it into sites/default?

rajeshwari10’s picture

Assigned: Unassigned » rajeshwari10
Status: Needs work » Needs review
StatusFileSize
new562 bytes

Hi

I have kept development.services.yml in sites folder as it is in drupal 8.1.x.

Just added the path sites/development.services.yml in git ignore. I had just given a try.

Please review.

Thanks!!

Status: Needs review » Needs work

The last submitted patch, 25: example_git_ignore-2381091-25.patch, failed testing.

rajeshwari10’s picture

Assigned: rajeshwari10 » Unassigned

The last submitted patch, 22: 2381091-22-example-gitignore.patch, failed testing.

lluvigne’s picture

Status: Needs work » Needs review
StatusFileSize
new819 bytes

Rerolled patch on #22 (i think that patch on #25 is not ok, maybe with this you can make the change, i don't know).

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

gnuget’s picture

Status: Needs review » Needs work

This still doesn't address #24.

whether we have or not to move the development.services.yml to site/default the default place of that file is /sites/ and IMO we should ignore it there by default.

gnuget’s picture

Status: Needs work » Needs review
StatusFileSize
new689 bytes
new821 bytes

Let's see if this can push this forward.

shadcn’s picture

+++ b/example.gitignore
@@ -29,7 +31,10 @@ sites/simpletest
+# **/*services*.yml

Wouldn't this line here ignore modules' services.yml files in a multisite configuration?

gnuget’s picture

Status: Needs review » Needs work

Yup, you are right. that line is even going to ignore /sites/default/services.yml file :-|

We need add an extra line there with something like:

!sites/*/services.yml

Thanks for your review, this definitely needs work.

gnuget’s picture

Version: 8.2.x-dev » 8.3.x-dev
Issue tags: +Novice
xjm’s picture

Version: 8.3.x-dev » 8.4.x-dev
sidharthap’s picture

Status: Needs work » Needs review
StatusFileSize
new825 bytes

Updated patch.

gnuget’s picture

Hi sidharthap.

Thanks for your patch, when a new patch is uploaded is necessary provide the interdiff as well.

Can you please upload it?

Thanks!

gnuget’s picture

I'm confuse.

Initially I thougth to we wanted to ignore all the files but settings.php and services.yml but it seems to I was wrong, we wanted to ignore all of them but example.settings.php and example.services.yml?

If that is the case then: 32 is correct.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joelpittet’s picture

Status: Needs review » Needs work
Issue tags: +Vienna2017

It seems that this issue title and summary doesn't match. Please update the title and summary to explain what this issue has evolved into.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

rassoni’s picture

Status: Needs work » Needs review
StatusFileSize
new827 bytes

#37 is not applied not 10.x. version. no changes in patch just re-roll in 10.x.

Status: Needs review » Needs work

The last submitted patch, 52: 3203420-52.patch, failed testing. View results

ankit_rathore’s picture

Status: Needs work » Needs review
StatusFileSize
new1.73 KB
new827 bytes

#52 failed because only changing
/example.gitignore
will not work, patch will work after adding the same lines in
/core/assets/scaffold/files/example.gitignore

I am uploading updated patch for 10.1.x-dev with interdiff

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue under control, following Review a patch or merge request as a guide.

This appears to need an issue summary as there seem to be more changes then what's originally listed. Using the default template would be super helpful.

===========

Just FYI to help get the message out there.

Starting March 2023, simple rerolls, rebases, or merges will no longer receive issue credit. Only rerolls that address a merge conflict will be credited, and the merge conflict that was resolved must be documented in the text of an issue comment.
To receive credit for contributing to this issue, assist with other outstanding tasks or unaddressed feedback.
See the issue credit guidelines for more information.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mdranove made their first commit to this issue’s fork.

mdranove’s picture

Title: development.services.yml is not included in example.gitignore » Improve example.gitignore
Issue summary: View changes

mdranove’s picture

Status: Needs work » Needs review
gengo_k’s picture

Issue tags: +Nara2025
gengo_k’s picture

Thanks for your work on this issue.

I performed Novice Triage on this issue. I am leaving the Novice tag on this issue because it has a clear step to review the short MR.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs issue summary update

Seems straight forward enough.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Why do we need ** for services and not for settings. And the recommendation for when .gitignore is inside sites is wrong.

alexpott’s picture

Issue tags: -Quick fix

Nothing about this has been quick.

ressa’s picture

Wouldn't it be more fruitful to focus on completing #3082958: Add gitignore(s) to Composer-ready project templates instead? It will place a .gitignore file in the project root automatically, upon creation via Composer.

Also, I believe multisite installations are such a rare occurrence, that perhaps it would fit better on a documentation page?

xjm’s picture

At either DrupalCon Vienna or Nara I told someone verbally this needed framework manager review, which somehow never made it back onto the issue, but looks like @alexpott found it anyway which is good.

I think #66 makes sense, but is also sort of implementation details. Regardless of where it goes, we need to agree on the contents. We could mark one or the other of these issues as duplicates or at least postponed on the other.

xjm’s picture

Issue tags: -Novice

Also no longer in a novice status. Thanks!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone made their first commit to this issue’s fork.

quietone’s picture

Status: Needs work » Needs review

Based on #67 I am going to postpone 'the other one', #3082958: Add gitignore(s) to Composer-ready project templates. Today, it seems better to make a small, incremental fixes.

I have applied the suggestions made by alexpott and rebased.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Rebased this one and from what I can tell all feedback has been addressed.

alexpott’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 046e7595b88 to main and 59a2ce11bb3 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 59a2ce11 on 11.x
    task: #2381091 Improve example.gitignore
    
    By: mikeker
    By: dawehner
    By:...

  • alexpott committed 6d986393 on main
    task: #2381091 Improve example.gitignore
    
    By: mikeker
    By: dawehner
    By:...
bramdriesen’s picture

Nice, glad to see this fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.