Skip to content
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

Allow users to select a template for an empty or missing gitignore #2197

Open
donokuda opened this issue Jul 6, 2017 · 11 comments · May be fixed by #14943
Open

Allow users to select a template for an empty or missing gitignore #2197

donokuda opened this issue Jul 6, 2017 · 11 comments · May be fixed by #14943
Labels
design-input-needed Issues that require design input from the core team before the work can be started enhancement good first issue Issues marked as ideal for a brand new contributor to start with

Comments

@donokuda
Copy link
Contributor

donokuda commented Jul 6, 2017

From #2160 (comment)

It's be nice if we could expose a drop down that allows users to start from a template. I'm thinking having that description there is not necessary; putting the description behind a tooltip should allow people who want/need to know what a gitignore file is to see it while allowing us to use that space for showing the file's contents.

@donokuda donokuda added enhancement design-input-needed Issues that require design input from the core team before the work can be started labels Jul 6, 2017
@nycdotnet
Copy link

nycdotnet commented Jul 1, 2021

I often run into this and wish there was a way to apply a .gitignore template to an existing repository. The reason for this is that I very often start my repositories with git init and then add to GitHub Desktop later.

I would like to propose something like the following:

  1. If there is an existing .gitignore in the repository, there are no changes.
  2. If there IS NOT an existing .gitignore in the repository, follow the below.
  • Extend the height of the existing Repository Settings... Ignored Files... tab slightly. Add a radio selector with a boldface description indicating that there is no .gitignore (this copies the design of the existing Git Config tab in the same dialog). The two options should be "Create a .gitignore file manually" and "Create a .gitignore file from a template".

New default tab state when no .gitignore
IgnoredProposedManual

  • If the option to create a .gitignore file manually is selected, the behavior of the dialog is the same. If the user enters some content into the text area and saves, a .gitignore file will be created, just as before.
  • If the option to create a .gitignore file from a template is selected, the user will be presented with a dropdown of the known templates. This dropdown is already implemented on the create new repository page. If the user selects an option other than None, and clicks save, that template will be used to create a .gitignore file.

New tab state when no .gitignore and from template selected

IgnoredProposedTemplate

From template selected and dropdown clicked

IgnoreProposedTemplate-withdropdown

  • Once a .gitignore file is created, the dialog returns to its original behavior in the presence of a .gitignore. This new experience is only available if the repo does not have a .gitignore.

@sergiou87 @shiftkey would you accept a PR implementing this?

Please forgive my slightly wonky screenshots - my photo editing skills are fairly basic.

@sergiou87
Copy link
Member

Hi @donokuda !

Thank you for your suggestion. We discussed about this and we're definitely open to accept PRs, but we think your approach might conflict a bit with how .gitignore is supposed to work: handling the file manually or from a template shouldn't be an (exclusive) option. Instead, users should be able to create a .gitignore file from a template and then edit it manually.

With that in mind, we think it's better to detect when the .gitignore file is empty, and then show something to allow the user creating a .gitignore file from a template. That something might be, for example (we're open to suggestions), some kind of hint text here:

2021-07-20 at 10 30

Once the .gitignore file is not empty anymore, that something would be removed and you can just edit the file manually.

What do you think?

@sergiou87 sergiou87 added the good first issue Issues marked as ideal for a brand new contributor to start with label Jul 20, 2021
@nycdotnet
Copy link

nycdotnet commented Jul 20, 2021

Sure that's probably even simpler. In my original proposal, the user would have to save with the template selected and then go back into the repo dialog to edit it (and since there would be a .gitignore file present, the UX would be the same as it exists today). I was operating under the assumption that most developers would only want to create the .gitignore from a template in this dialog and then proceed to edit it in a fully-featured text editor, but I suppose this may be my own bias.

It sounds like your proposal is to allow the user to make immediate edits without having to save first. If so, when does the .gitignore actually get written to disk? On Save? I suppose that makes the most sense, in which case, the template picker would really be about copying the template content into the text area rather than actually creating the file.

To flesh out this idea:

If the .gitignore text area has any content, there are no changes to the existing UX.

If the .gitignore text area is empty, a hyperlink that says "Create from template" or similar appears after the Learn More link. Clicking this causes the .gitignore template dropdown to appear above the text area along with adjacent OK and Cancel buttons. When this dropdown is visible, the text area should be readonly. Picking a template in the dropdown will fill the text area with the content from that template immediately. The user should be able to scroll around and look at the content in the text area (and even copy stuff out of it), but not be able to modify it. If the user clicks Cancel, the text area is cleared and the UI state reverts to what it was before the dropdown was displayed (aka empty .gitignore text area and "Create from template" link showing). If the user clicks OK, the dropdown, OK, and Cancel buttons disappear, and the text area keeps the content of the selected template and becomes editable. If they then click Save, the .gitignore is then written to disk (no changes to existing behavior). If they they instead click Cancel, no .gitignore is written (no changes to existing behavior).

@gg187on
Copy link

gg187on commented Oct 4, 2021

Hello, I would like to work on this issue, if it's avaiable.

@nycdotnet
Copy link

go for it imo

@bytrangle
Copy link

@sergiou87 Is help still needed on this issue?

@steveward
Copy link
Member

@bytrangle you're welcome to work on this!

@thenewpotato
Copy link

thenewpotato commented Jul 1, 2022

@sergiou87 @bytrangle Is anyone still working on this issue? If not, could I jump in?

@thenewpotato
Copy link

Just to clarify the behavior of the approach @sergiou87 laid out. I'm thinking the something between the label and the text field should be a dropdown menu where the user can select a gitignore template. This dropdown selection would default to "None." Once the user selects a template, the text field is automatically populated with that template, and the user has the ability to make further edits. This is slightly different from what @nycdotnet laid out, so let me know how this sounds to anyone on the team.

Also, as I understand it, we don't want this dropdown menu to show up when the gitignore is not empty, correct?

@thenewpotato
Copy link

Any updates on this? Just wanted to make sure this task is available and clear the design before I start working on this.

@Galvngif1207
Copy link

From #2160 (comment)

It's be nice if we could expose a drop down that allows users to start from a template. I'm thinking having that description there is not necessary; putting the description behind a tooltip should allow people who want/need to know what a gitignore file is to see it while allowing us to use that space for showing the file's contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-input-needed Issues that require design input from the core team before the work can be started enhancement good first issue Issues marked as ideal for a brand new contributor to start with
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants