What is the difference between "npm init " and "git init "?

1.1k Views Asked by At

sometimes I get confused what is the differences between npm init and git init when I want to start a project. I do not know where and when I should use each of them?

Can I use them together or I should use them separately?

Should I use them just at the start of the project or I can use them anytime?

2

There are 2 best solutions below

1
On

Source control (Git in this case, but there are other systems) is used to track and preserve history of source code changes over time.

Pro Git Book

A package manager (NPM in this case, but there are others like nuget), help one manage and include third party libraries into ones code. In the case of NPM specifically, it also may contain scripts or configuration that declares information about your project, like name, version, description, and where, online, your code is hosted (i.e. its source control).

About NPM

So to answer your question about when they should be used:

  • Git should generally be used for most projects
  • NPM should be used when you need to include third party libraries you want to use from the NPM repository.
0
On

Description. npm init can be used to set up a new or existing npm package. initializer in this case is an npm package named create- , which will be installed by npx , and then have its main bin executed -- presumably creating or updating package.

///////////////////////Git init //////////////////////////////////// The git init command creates a new Git repository. It can be used to convert an existing, unversioned project to a Git repository or initialize a new, empty repository. Most other Git commands are not available outside of an initialized repository, so this is usually the first command you'll run in a new project.

////////////////////////////////////////////////////////////