New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix .gitignore for var dir #863

Merged
merged 1 commit into from Nov 29, 2015

Conversation

Projects
None yet
9 participants
@ogizanagi
Member

ogizanagi commented Oct 7, 2015

Yeah, it's actually pretty ugly, but AFAIK, it's the only way to keep the whole var/ directory ignored, except those specific files in subdirectories.
Also, since the recently merged #857, SymfonyRequirements.php is being ignored.

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Oct 7, 2015

Contributor

What about this:

-/var/*
-!/var/cache
/var/cache/*
!var/cache/.gitkeep
-!/var/logs
/var/logs/*
!var/logs/.gitkeep
-!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
+/var/*
!var/SymfonyRequirements.php

Could it work by moving /var/* at the end of the file? I don't know if Git takes the order in account 😕 It could be a bit better-looking..

Contributor

Pierstoval commented Oct 7, 2015

What about this:

-/var/*
-!/var/cache
/var/cache/*
!var/cache/.gitkeep
-!/var/logs
/var/logs/*
!var/logs/.gitkeep
-!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
+/var/*
!var/SymfonyRequirements.php

Could it work by moving /var/* at the end of the file? I don't know if Git takes the order in account 😕 It could be a bit better-looking..

@ogizanagi

This comment has been minimized.

Show comment
Hide comment
@ogizanagi

ogizanagi Oct 7, 2015

Member

I tried your example just to be sure...but it doesn't work and exclude the whole /var/ dir.

Member

ogizanagi commented Oct 7, 2015

I tried your example just to be sure...but it doesn't work and exclude the whole /var/ dir.

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Oct 7, 2015

Contributor

It's strange that simply removing the !/var/sessions and alikes does not work 😕
Indeed it's ugly, but it makes me wonder of how .gitignore really works...

Contributor

Pierstoval commented Oct 7, 2015

It's strange that simply removing the !/var/sessions and alikes does not work 😕
Indeed it's ugly, but it makes me wonder of how .gitignore really works...

@DavidBadura

This comment has been minimized.

Show comment
Hide comment
@DavidBadura

DavidBadura Oct 13, 2015

why do you need to keep specific files or folders? these are generated automatically if they are missing. I have some projects for a long time with this config. it work's without problems.

DavidBadura commented Oct 13, 2015

why do you need to keep specific files or folders? these are generated automatically if they are missing. I have some projects for a long time with this config. it work's without problems.

@hacfi

This comment has been minimized.

Show comment
Hide comment
@hacfi

hacfi Oct 13, 2015

I think it’s good idea to check in the directories to avoid permission issues. Will check the PR later today.

hacfi commented Oct 13, 2015

I think it’s good idea to check in the directories to avoid permission issues. Will check the PR later today.

@DavidBadura

This comment has been minimized.

Show comment
Hide comment
@DavidBadura

DavidBadura Oct 13, 2015

the whole var folder should be writable by the web server. it should be no problem to create the missing files and folders.

DavidBadura commented Oct 13, 2015

the whole var folder should be writable by the web server. it should be no problem to create the missing files and folders.

@jvasseur

This comment has been minimized.

Show comment
Hide comment
@jvasseur

jvasseur Oct 13, 2015

@DavidBadura The var/bootstrap.php.cache should probably not be writable by the web server.

jvasseur commented Oct 13, 2015

@DavidBadura The var/bootstrap.php.cache should probably not be writable by the web server.

@DavidBadura

This comment has been minimized.

Show comment
Hide comment
@DavidBadura

DavidBadura Oct 13, 2015

We save the thumbnails, uploads etc. in that folder, which in turn is stored by the webserver. Instead of inserting all folders and files into the gitignore-file, we should consider removing the files that shouldn't be ignored from the var folder. This is only about 'var/bootstrap.php.cache' - right?

DavidBadura commented Oct 13, 2015

We save the thumbnails, uploads etc. in that folder, which in turn is stored by the webserver. Instead of inserting all folders and files into the gitignore-file, we should consider removing the files that shouldn't be ignored from the var folder. This is only about 'var/bootstrap.php.cache' - right?

@Tobion

This comment has been minimized.

Show comment
Hide comment
@Tobion

Tobion Nov 29, 2015

Member

Thank you @ogizanagi.

Member

Tobion commented Nov 29, 2015

Thank you @ogizanagi.

@Tobion Tobion merged commit a4a812c into symfony:master Nov 29, 2015

1 check passed

fabbot.io Your code looks good.
Details

Tobion added a commit that referenced this pull request Nov 29, 2015

bug #863 Fix .gitignore for var dir (ogizanagi)
This PR was merged into the 3.0-dev branch.

Discussion
----------

Fix .gitignore for var dir

Yeah, it's actually pretty ugly, but AFAIK, it's the only way to keep the whole `var/` directory ignored, except those specific files in subdirectories.
Also, since the recently merged #857, `SymfonyRequirements.php` is being ignored.

Commits
-------

a4a812c Fix .gitignore for var dir

@ogizanagi ogizanagi deleted the ogizanagi:ignore_var_fix branch Nov 29, 2015

@Tobion

This comment has been minimized.

Show comment
Hide comment
@Tobion

Tobion Nov 29, 2015

Member

I tested this and it indeed fixes the problem. This appraoch is also descibed in http://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder
It's ugly but the way it has to be to keep the cache/log/session dir as we currently do.

Btw, there would be an alternative: instead of using .gitkeep we could use a .gitignore in the cache/log/session dir with

*
!.gitignore

and the root gitingore would only do !/var/cache. But at the end it's the same amount of lines and having it at root in one place is often considered better.

Member

Tobion commented Nov 29, 2015

I tested this and it indeed fixes the problem. This appraoch is also descibed in http://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder
It's ugly but the way it has to be to keep the cache/log/session dir as we currently do.

Btw, there would be an alternative: instead of using .gitkeep we could use a .gitignore in the cache/log/session dir with

*
!.gitignore

and the root gitingore would only do !/var/cache. But at the end it's the same amount of lines and having it at root in one place is often considered better.

@drAlberT

This comment has been minimized.

Show comment
Hide comment
@drAlberT

drAlberT May 26, 2016

AFAICS appending only one !*/.gitkeep line at the end of the file should suffice

/app/config/parameters.yml
 /build/
/phpunit.xml
/var/**
!/var/SymfonyRequirements.php
/vendor/
/web/bundles/
!*/.gitkeep

@ogizanagi @fabpot What do you think? .. Am I wrong?

drAlberT commented on a4a812c May 26, 2016

AFAICS appending only one !*/.gitkeep line at the end of the file should suffice

/app/config/parameters.yml
 /build/
/phpunit.xml
/var/**
!/var/SymfonyRequirements.php
/vendor/
/web/bundles/
!*/.gitkeep

@ogizanagi @fabpot What do you think? .. Am I wrong?

This comment has been minimized.

Show comment
Hide comment
@stof

stof May 26, 2016

Member

@drAlberT I think it depends on your git version. IIRC there was a bug in git for a long time preventing your suggestion to work.

Member

stof replied May 26, 2016

@drAlberT I think it depends on your git version. IIRC there was a bug in git for a long time preventing your suggestion to work.

This comment has been minimized.

Show comment
Hide comment
@drAlberT

drAlberT May 26, 2016

@stof ah ok .. didn't know about this bug

Have you any reference to it .. just for curiosity .. I'm using the suggested syntax on my projects and I'd like to go deeper

Thank you

drAlberT replied May 26, 2016

@stof ah ok .. didn't know about this bug

Have you any reference to it .. just for curiosity .. I'm using the suggested syntax on my projects and I'd like to go deeper

Thank you

This comment has been minimized.

Show comment
Hide comment
@JLepeltier

JLepeltier Dec 12, 2016

On the var/SymfonyRequirements.php file we can read "DO NOT EDIT THIS FILE as it will be overridden by Composer" so why not ignoring it ? Same question for the web/config.php

JLepeltier replied Dec 12, 2016

On the var/SymfonyRequirements.php file we can read "DO NOT EDIT THIS FILE as it will be overridden by Composer" so why not ignoring it ? Same question for the web/config.php

This comment has been minimized.

Show comment
Hide comment
@stof

stof Dec 12, 2016

Member

@JLepeltier the goal of having it in the symfony-standard repo directly is to allow people to check requirements before they run composer. This is probably less relevant since the introduction of the symfony installer though.

Member

stof replied Dec 12, 2016

@JLepeltier the goal of having it in the symfony-standard repo directly is to allow people to check requirements before they run composer. This is probably less relevant since the introduction of the symfony installer though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment