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?
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: