Add version control to nodejs project

Add version control to nodejs project

This article shows how to use Git and GitHub source code management services.

Make sure that you already have installed git:

git --version

If you don’t have installed git on your machine, please see Install and setup git and GitHub.

1. Visit the GitHub page, sign-up, and create empty repositories.

2. Follow these instructions to add your project to the remote repository:

touch .gitignore

And add this to .gitignore:

# Node artifact files
node_modules/
dist/

# JetBrains IDE
.idea/

After it, the project is ready to use the git version control system.

3. Run the command to init git:

git init

4. Track all files in your project:

git add .

3. Setup user info, do not forget to change these user data to your own:

 git config --global user.email "you@example.com" &&  git config --global user.name "Your Name"

4. Commit changes:

git commit -m "init project"

5. Create the main branch:

git branch -M main

6. Here, be careful. You need to add precisely the proper remote repository. In my case, it looks like the command below (you have another remote repository):

git remote add origin git@github.com:comfortdev/nodejs_app.git

7. Push changes to the remote repository:

git push -u origin main

Now you can navigate to GitHub and see your changes on the remote repository.

Leave a Reply

Your email address will not be published. Required fields are marked *