Bug 558021 - Consider creating an empty .gitignore file during the creation of a new Git repo
Summary: Consider creating an empty .gitignore file during the creation of a new Git ...
Status: RESOLVED WONTFIX
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2019-12-09 06:38 EST by Lars Vogel CLA
Modified: 2019-12-10 08:12 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2019-12-09 06:38:36 EST
Would be nice to have an .gitignore created or to have the option in the wizard to do so.
Comment 1 Thomas Wolf CLA 2019-12-10 01:23:30 EST
Short version: why?

Long version: what's the motivation behind this request?
Comment 2 Lars Vogel CLA 2019-12-10 01:52:00 EST
(In reply to Thomas Wolf from comment #1)
> Short version: why?
> 
> Long version: what's the motivation behind this request?

IMHO every Git repo needs a .gitignore.
Comment 3 Thomas Wolf CLA 2019-12-10 03:36:25 EST
Perhaps... though I can find easily a git repo on Github that doesn't have and doesn't need one.

In what way does creating an empty .gitignore help? Until it's filled with actual patterns, it doesn't serve any purpose. It only makes working tree traversals a little slower, and makes the newly created git repo immediately dirty. This is a gratuitous difference to command-line git that's likely to confuse beginners. I don't think this is going to be helpful.
Comment 4 Matthias Sohn CLA 2019-12-10 04:15:37 EST
I second Thomas' opinion, I think the decision to create a .gitignore should be left to the user.

I checked git repository templates [1] and found that git init --template=<template directory> does not copy dotfiles from the template directory to a newly created repository.

[1] https://git-scm.com/docs/git-init#_template_directory
Comment 5 Lars Vogel CLA 2019-12-10 04:36:56 EST
(In reply to Matthias Sohn from comment #4)
> I second Thomas' opinion, I think the decision to create a .gitignore should
> be left to the user.

I expected that, hence the second suggestion:.... or to have the option in the wizard to do so.
Comment 6 Thomas Wolf CLA 2019-12-10 05:34:44 EST
(In reply to Lars Vogel from comment #5)
> I expected that, hence the second suggestion:.... or to have the option in
> the wizard to do so.

I had seen that :-) but I don't understand what the benefit of creating an empty .gitignore is.
Comment 7 Matthias Sohn CLA 2019-12-10 07:38:45 EST
(In reply to Thomas Wolf from comment #6)
> (In reply to Lars Vogel from comment #5)
> > I expected that, hence the second suggestion:.... or to have the option in
> > the wizard to do so.
> 
> I had seen that :-) but I don't understand what the benefit of creating an
> empty .gitignore is.

we could add another wizard page asking for the content of .gitignore if the option is set by the user
Comment 8 Thomas Wolf CLA 2019-12-10 07:46:42 EST
(In reply to Matthias Sohn from comment #4)
> I checked git repository templates [1] and found that git init
> --template=<template directory> does not copy dotfiles from the template
> directory to a newly created repository.
> 
> [1] https://git-scm.com/docs/git-init#_template_directory

Yes, but it could be used to provide a repo-specific exclude file ($GIT_DIR/info/exclude).

But templates are copied to $GIT_DIR anyway, not to the working tree, so not likely to be what Lars had in mind.
Comment 9 Thomas Wolf CLA 2019-12-10 08:07:31 EST
(In reply to Matthias Sohn from comment #7)
> we could add another wizard page asking for the content of .gitignore if the
> option is set by the user

First, I don't think that makes it any easier than just having the user create the .gitignore file with content once the repo has been created.

Second, I think this kind of inverts the workflow. A user would have to define the .gitignore before even populating the repo with real content, but what should be in the .gitignore depends on what the real content will be. (For maven projects, you'd want to exclude target/, but if you don't have maven projects but plain Java projects, it's probably bin/. If you're going to build with bazel, probably /.bazel*/, and so on.) If he knows already (perhaps he has an existing .gitignore file), then he can just as well simply copy that file after having created the repo.

I also don't think we should encourage people to copy-paste random examples from the Internet, like these humongous catch-it-all examples one can find that exclude all kinds of IDE- and platform-specific files and folders. git ignore files with superfluous patterns can make file tree traversals needlessly slow, since file names have to be checked against umpteen patterns. Platform-specific patterns can go in the user gitignore (can be set via git config core.excludesfile if the system config doesn't define a location already), and excluding IDE-specific things is IMO a bad idea anyway since it'll make it harder to get everyone working on a repo use consistent settings.
Comment 10 Matthias Sohn CLA 2019-12-10 08:12:10 EST
ok, makes sense, then let's respond to this request with won't fix