Skip to content

ng new --skip-git/--skipGit should not skip creating .gitignore file #8638

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

Closed
ADTC opened this issue Nov 26, 2017 · 9 comments
Closed

ng new --skip-git/--skipGit should not skip creating .gitignore file #8638

ADTC opened this issue Nov 26, 2017 · 9 comments
Labels
area: @schematics/angular feature Issue that requests a new feature
Milestone

Comments

@ADTC
Copy link

ADTC commented Nov 26, 2017

Versions

Angular CLI: 1.5.3                                           @angular/cli: 1.5.3
Node: 8.9.1                                                  @angular-devkit/build-optimizer: 0.0.33
OS: win32 x64                                                @angular-devkit/core: 0.0.21
Angular: 5.0.3                                               @angular-devkit/schematics: 0.0.37
... animations, common, compiler, compiler-cli, core, forms  @ngtools/json-schema: 1.1.0
... http, language-service, platform-browser                 @ngtools/webpack: 1.8.3
... platform-browser-dynamic, router                         @schematics/angular: 0.1.7
                                                             typescript: 2.4.2
Windows 10 x64                                               webpack: 3.8.1

Repro steps

  1. Use ng new --skip-git to create a new project without a Git repository.
  2. Open the project folder and look for .gitignore file.

Observed behavior

The .gitignore file does not exist.

Desired behavior

What would like to see implemented?

The .gitignore file should be generated and added to the project.

What is the use case?

  • Project may be part of a larger project that already has a Git repository.
  • Project may have a Git repository initialized later.

What did you expect to see?

The .gitignore file exists.

Mention any other details that might be useful (optional)

A .gitignore file is still very useful even if no Git repository was initialized. This is because the project may be part of a larger project which already has a Git repository or uses another gitignore-aware VCS. Or a Git repository may be added to the project later. In either case, you do not want all the build files, modules, IDE files, e2e files and whatnot to be checked in to the repository.

For anyone that may never use Git with the project, the .gitignore file is just a small harmless additional file in the project, so it's not an issue there.

Relates to #4854

@Survivedabuse
Copy link

@ADTC

@beeman
Copy link
Contributor

beeman commented Nov 26, 2017

This is by design #3713

@ADTC
Copy link
Author

ADTC commented Nov 26, 2017

I now understand it's by design. But what about the use cases I had described?

@beeman
Copy link
Contributor

beeman commented Nov 27, 2017

@ADTC I think this is such a specific use case that the best option would be to not use the --skip-git flag and just rm -rf .git after you ran the ng new command.

If it's part of a bigger repo you might have to customize it already, the Angular CLI aims to set defaults that work for most situations, but it can never accommodate to any situation.

@Brocco might have more ideas about it.

@filipesilva filipesilva added the needs: investigation Requires some digging to determine if action is needed label Nov 27, 2017
@hansl hansl unassigned Brocco Feb 6, 2018
@Executus
Copy link

Here's another use case using VSTS (Visual Studio Online):

  1. Create empty git project in VSTS
  2. Clone git project on client
  3. Create angular app with --skip-git flag, as we don't want to init a new repo. However we still want the gitignore.

@NeeLonGithub
Copy link

NeeLonGithub commented Jun 9, 2019

I expect --skip-git to skip the git processes (init and first commit).
In my case I just don't want the first commit to be done with my global settings, so I want to skip the git processes and do them myself later.
For an option that expects the project to be oblivious of git and therefore not even create a .gitignore, I would expect --no-git or something similar.

@filipesilva filipesilva added area: @schematics/angular feature Issue that requests a new feature and removed needs: investigation Requires some digging to determine if action is needed labels Oct 8, 2019
@ngbot ngbot bot modified the milestone: Backlog Oct 8, 2019
@clydin clydin added the needs: discussion On the agenda for team meeting to determine next steps label May 26, 2020
@dgp1130
Copy link
Collaborator

dgp1130 commented Jun 26, 2020

Discussed this in a CLI meeting today. Unfortunately not much justification was given in the original PR, so it's hard to know the major reasons for removing .gitignore beyond "It's related to Git".

In our discussion, we had the following points:

  • It's easier to delete than to add .gitignore for Angular's specific file structure.
  • IDEs and tools often use .gitignore to filter unwanted files.
  • The existing --skip-package-manager flag just skips the npm/yarn binary, it still generates package.json. So having --skip-git just skip the git init call but create .gitignore would be more consistent.

OTOH:

  • If you're using a different VCS, you'd not want to bother with .gitignore at all (though no other VCS is directly supported right now).
  • We could add another flag (for example --no-git) as someone suggested, but this would be very confusing when compared to the existing --skip-git and the subtle distinction between them would hard to communicate to users.
  • Changing the existing behavior does cause some churn in the ecosystem and user base.

Users could be creating an Angular application in a directory already under source control, though we already handle that today and include .gitignore while skipping git init. So I think we're already doing the right thing here without needing the user to specify an extra flag.

douglasparker@basilisk (~/Source)                                                                        
[20-06-26 10:15:05]$ mkdir git
mkdir: created directory 'git'
douglasparker@basilisk (~/Source)
[20-06-26 10:15:08]$ cd git/                                                                           
douglasparker@basilisk (~/Source/git)
[20-06-26 10:15:10]$ git init                                                                            
Initialized empty Git repository in /home/douglasparker/Source/git/.git/                                 
douglasparker@basilisk (~/Source/git)                                                                    
[20-06-26 10:15:13]$ ng new --defaults ng
# ...
CREATE ng/.gitignore (631 bytes)
# ...
✔ Packages installed successfully.
    Directory is already under version control. Skipping initialization of git.

There's also the somewhat related question of app/assets/.gitkeep, which is also related but doesn't have the same benefits as .gitignore. It's just there so the assets/ folder gets committed.

Based on these points, the consensus of the team is to include .gitignore even when --skip-git is requested. IDEs and other tools will generally work better with this file present and it is trivial to delete it if the user really doesn't want it. If we support other VCS tools in the future, then we may want to revisit this decision.

@dgp1130 dgp1130 removed the needs: discussion On the agenda for team meeting to determine next steps label Jun 26, 2020
@alan-agius4 alan-agius4 changed the title ng new --skip-git should not skip creating .gitignore file ng new --skip-git/--skipGit should not skip creating .gitignore file Jul 6, 2020
@alan-agius4
Copy link
Collaborator

Closing as per above.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @schematics/angular feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

10 participants