Add a minimal Gitignore

233 views
Skip to first unread message

Daniel Azubuine

unread,
Mar 9, 2023, 11:44:52 AM3/9/23
to Django developers (Contributions to Django itself)
I think it will be a little bit helpful to add a very minimal .gitignore file to the django project.
Maybe one that just ignores the environments, test files

Adam Johnson

unread,
Mar 9, 2023, 1:27:35 PM3/9/23
to django-d...@googlegroups.com
The Django project has a .gitignore file: https://github.com/django/django/blob/main/.gitignore

On Thu, Mar 9, 2023 at 3:46 PM Daniel Azubuine <azubuine...@gmail.com> wrote:
I think it will be a little bit helpful to add a very minimal .gitignore file to the django project.
Maybe one that just ignores the environments, test files

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/3c71bbfb-b205-434b-8a1c-c15ceaba3dbbn%40googlegroups.com.

James Bennett

unread,
Mar 9, 2023, 2:00:59 PM3/9/23
to django-d...@googlegroups.com
On Thu, Mar 9, 2023 at 10:27 AM 'Adam Johnson' via Django developers (Contributions to Django itself) <django-d...@googlegroups.com> wrote:
The Django project has a .gitignore file: https://github.com/django/django/blob/main/.gitignore
I think this person was asking for the default ‘startproject’ template to include a minimal .gitignore file. 

Daniel Azubuine

unread,
Mar 9, 2023, 2:13:22 PM3/9/23
to django-d...@googlegroups.com
Yeah

What I meant is for the default ‘startproject’ template to include a minimal .gitignore file.

I've added the template. 
Just wanted to ask before I push

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.

Arthur Pemberton

unread,
Mar 9, 2023, 2:40:19 PM3/9/23
to django-d...@googlegroups.com
I like the idea as I've seen novices commit all their .pyc files, but maybe this should only triggered by a flag to startproject, --git perhaps.

Arthur Pemberton

Daniel Azubuine

unread,
Mar 9, 2023, 3:07:03 PM3/9/23
to django-d...@googlegroups.com
Yeah.

Nice idea! Arthur!
I'll do that

Mariusz Felisiak

unread,
Mar 10, 2023, 12:02:59 AM3/10/23
to Django developers (Contributions to Django itself)
Hi Daniel,

    Adding .gitignore to the project template has been discussed and rejected multiple times, e.g. https://github.com/django/django/pull/13847

Best,
Mariusz

Cory Zue

unread,
Mar 10, 2023, 2:11:03 AM3/10/23
to django-d...@googlegroups.com
Is there a more nuanced discussion of this issue anywhere? The reasons stated in the linked PR that it's "not for the project template to provide configuration for source code management tools" feels more like an opinion than a fact.

 I know one of the goals that emerged from recent discussions was how to get more wide adoption of the Django project. This strikes me as one of those simple little things that helps 95% of beginners and doesn't hurt the remaining 5%. If you don't want a .gitignore file, then you're also probably advanced enough to figure out how to build without it, or just delete it.

I just checked a few other frameworks:

Drupal / composer added it in 2020.
create-react-app generates one.
create-vue generates one

Perhaps it's time for Django to reconsider and catch up with the times?

Cory




--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.

Mariusz Felisiak

unread,
Mar 10, 2023, 3:39:07 AM3/10/23
to Django developers (Contributions to Django itself)
Hi,

I'm -1. "Other frameworks..." is not an argument for me, and I don't believe that `.gitignore` in the project template makes it more beginner friendly as I wouldn't call a beginner someone who use VCS.

Adding `.gitignore` assumes that folks always use Git, that's not true. Moreover, `.gitignore` is IDE-specific in most of cases, and we don't want to accept dozens of tickets for expanding `.gitignore` with `.idea`, `.vscode` etc.

My 2¢

Best,
Mariusz

Cory Zue

unread,
Mar 10, 2023, 4:19:32 AM3/10/23
to django-d...@googlegroups.com
Hey,

Thanks, I appreciate the response. It sounds like your main concern is the overhead of maintaining the .gitignore file, is that right? Could that potentially be mitigated by a clear writeup of what's included, why, and then an easy way to close all other tickets? E.g. we could easily just use github's Python default, declare that the policay, and call it day. Perhaps that overhead would be no less than having to have this conversation over and over again as it seems clear has already been happening.

As for the point that not everyone uses git, that's true, but according to the latest SO survey it's used by 94% of respondents. That seems like a pretty solid majority to help support, no?

thanks,
Cory

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.

Bogdan Barna

unread,
Mar 10, 2023, 10:01:25 AM3/10/23
to Django developers (Contributions to Django itself)
Just want to say that I agree with Cory. Being a non-core feature/issue, I don't see a reason of why not to re-evaluate the "denied" decisions.

Tom Carrick

unread,
Mar 10, 2023, 11:07:26 AM3/10/23
to django-d...@googlegroups.com
I don't really like the idea of this for a number of reasons.

A lot of people create the project in a subdirectory. For them, the gitignore is in the wrong place.

Enough people are using GitHub that they create the repo first with one of GH's provided gitignores, or copy it in after.

As Python changes, as new tools come out, the gitignore needs to be constantly updated. There will be a lot of bikeshedding about what should and shouldn't go in. For example, the .vscode directory sometimes has project specific code that should be included. Sometimes it should be excluded because devs are expected to set their own up or use whatever editor they prefer. Many users (such as myself) have .vscode in a global gitignore expressly so it doesn't need to be added to every project.

A lot of people are using a frontend framework, that won't be covered by our gitignore, and this framework might itself want to set up a gitignore.

The biggest problem for me is that it would just be a maintenance burden.

Cheers,
Tom


Adam Johnson

unread,
Mar 10, 2023, 11:12:23 AM3/10/23
to django-d...@googlegroups.com
I'm also against the idea, unless done in a very minimal fashion.

Many tools in the ecosystem put "ignore everything here" .gitignore files into their not-normally-committed directories: at least Coverage.py, Mypy, pytest, and virtualenv. So the trend is that less and less .gitignore patterns are needed for a Python project. I am not sure there are general Django patterns we could add except *.pyc , and maybe Python will start dropped .gitignore files in __pycache__ dirs at some point.

I don't think we could even add a pattern for ignoring .mo files from translations, since according to a poll I did last year, about 50% of devs commit them: https://twitter.com/AdamChainz/status/1557058307592015878 .

 we could easily just use github's Python default, declare that the policay, and call it day
 
GitHub’s Python default file is seriously bloated: https://github.com/github/gitignore/blob/main/Python.gitignore . Their maintenance policy seems to be “accept any suggestion, append-only”. We generally set a higher bar for Django.

The GitHub file includes patterns to ignore files generated by tools that have fallen out of favour (e.g. nosetests.xml for nose test runner). And it also includes low-specificity patterns that could confuse new Git users, such as target/ ignoring *all* directories named "target". Also the "Django stuff" patterns in there are related to non-universal ways of using Django.

I wouldn't want to burden all Django projects with so many irrelevant patterns. It takes work to understand and remove them.

Enough people are using GitHub that they create the repo first with one of GH's provided gitignores, or copy it in after.

Agree here that people can set up or use Git templates if they wish. Git itself has a repository template mechanism.

Tega Ukavwe

unread,
Mar 10, 2023, 11:37:15 AM3/10/23
to django-d...@googlegroups.com
I strongly agree with Adam and Tom, the extra and unnecessary burden of maintaining the .gitignore file outweighs its advantages.

Cheers,
Tega.

Arthur Pemberton

unread,
Mar 10, 2023, 11:47:48 AM3/10/23
to django-d...@googlegroups.com
What exactly would be considered the burden in maintaining a .gitignore?

Arthur

Jörg Breitbart

unread,
Mar 10, 2023, 12:14:14 PM3/10/23
to django-d...@googlegroups.com
Also -1 from my side.

Imho django should deal with django things, and not with other stuff
that may come handy on top. There are many more VCS than git, and even
with git in particular there are several ways to structure your repo. To
me this should stay a matter of VCS/repo tooling, not being specified by
django itself.

Cheers,
Jörg

Tega Ukavwe

unread,
Mar 10, 2023, 12:43:37 PM3/10/23
to django-d...@googlegroups.com
Here I quote Tom's reply to this thread: "As Python changes, as new tools come out, the gitignore needs to be constantly updated. There will be a lot of bikeshedding about what should and shouldn't go in. For example, the .vscode directory sometimes has project specific code that should be included."

I hope you understand,
Cheers,
Tega.

Reply all
Reply to author
Forward
0 new messages