Skip to main content

Create a Git repository

New repository

Initialize the repository

git init

Add gitignore file

touch .gitignore

Add the following to the .gitignore file

# Ignore node_modules folder
node_modules
.node_modules

Add all files to the repository

git add .

Commit the changes

git commit -m "Initial commit"

Connect to a remote repository

Create a new repository

Follow the instructions to create a new repository.

GitHub create a new repository

Add the remote repository

git remote add origin <url>

Verifty the remote repository

git remote -v

Setup the upstream branch

git remote --set-upstream origin <branch-name>

Push the changes to the remote repository

git push origin <branch-name>

Existing repository

git clone <url>

Create a new branch

git checkout -b <branch-name>

Push changes to a remote repository

git push origin <branch-name>