Why does "rails new my_app" initialize a git repository?

235 Views Asked by At

When I run the Ruby on Rails command rails new my_app, it creates the new my_app directory, and it contains a .git subdirectory, i.e., ./my_app/.git, so it's apparently doing a git init. Where is that git init command coming from, and why does it do that?

Rails version: 7.0.4.3
Ruby version: 3.0.1.p64

1

There are 1 best solutions below

0
Marcelo Paco On BEST ANSWER

Automatic initialization of a Git repo when creating a new app started in Ruby on Rails 5.1. The --skip-git option can be provided when creating a new app to stop git_init from happening. When the change was introduced the git_init command occurred in the app_generator.rb file. In the latest version of ruby on rails (v7.0.4.3), the git_init command occurs in the app_base.rb file.