You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Git Repo Creation Should Be Opt-In: --skip-git #4854
I ran ng new my-app inside a directory inside my Mercurial repo.
I observed many files in .git folder.
I had no expectation by running ng new my-app that a Git Repo would be created too. This command did something I didn't expect. I was highly confused; no documentation told me this would occur.
Suggestion A: This feature may be helpful for some, but not all. Make the feature OPT-IN, not OPT-OUT.
Suggestion B: Let the new command ask, via a workflow if a Git Repo is desired.
@beeman I think @majew7 point is that ng new assumes you want a git repo, when in a lot of cases the angular2 app may be part of a bigger repository. Given ng has no dependencies on git or git specific features, I kinda agree it would be nice if the command asked for confirmation before deciding to initialize a git repository.
Reacted by Michael Rarela, wndproc1 and Alex Koumparos
We try to stay away from prompts in general. I understand this was surprising behaviour, but it's quite telling that it took so long to be brought up. I think in most cases it's ok, and even when you don't want it it's trivial to 'correct' it.
Reacted by beeman
Reacted by Vitalii, Daniele Benegiamo and Andrew Krueger
I agree, it is totally screwing up my pushes since I push one main folder, and since all the subdirectories are initialized it doesn't want to add them no matter what I do, delete the .git, the .gitignore, add . -f, etc. The only thing I think would solve this is if the CLI didn't assume I wanted a new git init everytime I start a new project. Don't even need to prompt or make in opt-in/out, simply give us the option to git init when we decide to. So far I haven't found anything that rectifies this.
@pageza does --skip-git not work for you ? it's a reliable way to not generate the .git directory whenever you are initializing a new project. You can read more about it on the ng new documentation
I finally got that sorted for all my new projects. The point remains, it should be opt-in, instead of assuming I want all of my projects to be git initialized, or maybe at least a prompt asking if I want to init it.
Reacted by Michael Rarela, Wink Saville, Moritz Orth and Daniele Benegiamo
100% agree that a git repository should not be initialized by default. Use 'git init' if you want to create a new git repository for the new angular application. Version control is a completely separate activity to application creation (and git is not the only version control system out there...). Even if git is used for version control the user may not want to initialize a new repository but rather add the new application to an existing repository.
I agree with this as well. Although I am a Git user myself and I like that a Git repository could be used to version control my Angular project, I am quite surprised that a Git repository is initialized by default by a command that is not expected to do so. I totally agree that this should be an opt-in behavior, not an opt-out behavior.
The flag should really be --init-git, not --skip-git and the default behavior should be to not initialize a Git repo. The --init-git flag could be a nice shortcut to automatically initialize a Git repo and make an initial commit of the project (unless --skip-commit is given), but it should never be an imposed behavior of ng new.
Angular projects are in no way dependent on having a Git repository at their root and can function without one, so why create an unnecessary Git repo in every project? Some may not even bother about the repo at all, while others might find it frustrating that they have to clean up the mess by deleting the .git folder just because they forgot the --skip-git flag.
Sidenote issue:
One thing I noticed is that, giving the --skip-git option also skips creating a .gitignore file. It should not. I filed this in #8638.
Activity
beeman commentedon Feb 21, 2017
@majew7 the command
ng newinforms the user that a new git repo is initialised:Successfully initialized git.dave11mj commentedon Feb 21, 2017
@beeman I think @majew7 point is that
ng newassumes you want a git repo, when in a lot of cases the angular2 app may be part of a bigger repository. Givennghas no dependencies ongitorgitspecific features, I kinda agree it would be nice if the command asked for confirmation before deciding to initialize a git repository.filipesilva commentedon Feb 21, 2017
We try to stay away from prompts in general. I understand this was surprising behaviour, but it's quite telling that it took so long to be brought up. I think in most cases it's ok, and even when you don't want it it's trivial to 'correct' it.
pageza commentedon Aug 12, 2017
I agree, it is totally screwing up my pushes since I push one main folder, and since all the subdirectories are initialized it doesn't want to add them no matter what I do, delete the .git, the .gitignore, add . -f, etc. The only thing I think would solve this is if the CLI didn't assume I wanted a new git init everytime I start a new project. Don't even need to prompt or make in opt-in/out, simply give us the option to git init when we decide to. So far I haven't found anything that rectifies this.
dave11mj commentedon Aug 16, 2017
@pageza does
--skip-gitnot work for you ? it's a reliable way to not generate the.gitdirectory whenever you are initializing a new project. You can read more about it on the ng new documentationpageza commentedon Aug 16, 2017
I finally got that sorted for all my new projects. The point remains, it should be opt-in, instead of assuming I want all of my projects to be git initialized, or maybe at least a prompt asking if I want to init it.
patrickh1 commentedon Oct 9, 2017
100% agree that a git repository should not be initialized by default. Use 'git init' if you want to create a new git repository for the new angular application. Version control is a completely separate activity to application creation (and git is not the only version control system out there...). Even if git is used for version control the user may not want to initialize a new repository but rather add the new application to an existing repository.
ADTC commentedon Nov 26, 2017
I agree with this as well. Although I am a Git user myself and I like that a Git repository could be used to version control my Angular project, I am quite surprised that a Git repository is initialized by default by a command that is not expected to do so. I totally agree that this should be an opt-in behavior, not an opt-out behavior.
The flag should really be
--init-git, not--skip-gitand the default behavior should be to not initialize a Git repo. The--init-gitflag could be a nice shortcut to automatically initialize a Git repo and make an initial commit of the project (unless--skip-commitis given), but it should never be an imposed behavior ofng new.Angular projects are in no way dependent on having a Git repository at their root and can function without one, so why create an unnecessary Git repo in every project? Some may not even bother about the repo at all, while others might find it frustrating that they have to clean up the mess by deleting the
.gitfolder just because they forgot the--skip-gitflag.Sidenote issue:
One thing I noticed is that, giving the
--skip-gitoption also skips creating a.gitignorefile. It should not. I filed this in #8638.akrueger commentedon May 23, 2018
This seems to list "angular-cli" as the contributor for commits on all of my Github projects. Is there a way to change that?
angular-automatic-lock-bot commentedon Sep 8, 2019
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.