Repository navigation
ng new --skip-git/--skipGit should not skip creating .gitignore file #8638
Description
Activity
This is by design #3713
I now understand it's by design. But what about the use cases I had described?
@ADTC I think this is such a specific use case that the best option would be to not use the
--skip-gitflag and justrm -rf .gitafter you ran theng newcommand.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.
- addedneeds: investigationRequires some digging to determine if action is neededRequires some digging to determine if action is needed
on Nov 27, 2017 Here's another use case using VSTS (Visual Studio Online):
- Create empty git project in VSTS
- Clone git project on client
- Create angular app with --skip-git flag, as we don't want to init a new repo. However we still want the gitignore.
Reacted by arturhun, Balint Csaszar (Chassy), beeman, Caltor, Alexander Popelyuk and Драган ЋајићI expect
--skip-gitto 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-gitor something similar.Reacted by Caltor, Athul K A and Finley- addedfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesand removedneeds: investigationRequires some digging to determine if action is neededRequires some digging to determine if action is needed
on Oct 8, 2019 - addedneeds: discussionOn the agenda for team meeting to determine next stepsOn the agenda for team meeting to determine next steps
on May 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
.gitignorebeyond "It's related to Git".In our discussion, we had the following points:
- It's easier to delete than to add
.gitignorefor Angular's specific file structure. - IDEs and tools often use
.gitignoreto filter unwanted files. - The existing
--skip-package-managerflag just skips thenpm/yarnbinary, it still generatespackage.json. So having--skip-gitjust skip thegit initcall but create.gitignorewould be more consistent.
OTOH:
- If you're using a different VCS, you'd not want to bother with
.gitignoreat 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-gitand 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
.gitignorewhile skippinggit 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 theassets/folder gets committed.Based on these points, the consensus of the team is to include
.gitignoreeven when--skip-gitis 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.Reacted by kil0ba and Corneel Eijsbouts- It's easier to delete than to add
- removedneeds: discussionOn the agenda for team meeting to determine next stepsOn the agenda for team meeting to determine next steps
on Jun 26, 2020 - changed the title
[-]ng new --skip-git should not skip creating .gitignore file[/-][+]ng new --skip-git/--skipGit should not skip creating .gitignore file[/+]on Jul 6, 2020 Closing as per above.
Reacted by beemanangular-automatic-lock-bot commented
on Jun 26, 2021 More actionsThis 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.
- locked and limited conversation to collaborators
on Jun 26, 2021
Versions
Repro steps
ng new --skip-gitto create a new project without a Git repository..gitignorefile.Observed behavior
The
.gitignorefile does not exist.Desired behavior
The
.gitignorefile should be generated and added to the project.The
.gitignorefile exists.Mention any other details that might be useful (optional)
A
.gitignorefile 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
.gitignorefile is just a small harmless additional file in the project, so it's not an issue there.Relates to #4854