Go to GitLab or GitHub and create a new project (You should not create a project with README, as this will create a commit and conflicts).

type in the root of your local project:

git init

to initialize a new local Git repository:

  • git add: your files to the local repository with git add .
  • Commit the changes with git commit -m “Commit message”

link the local repository with the remote one:

git remote add origin <remote-repository-URL>

Replace with the URL of your GitLab/GitHUB repository or git any remote online repository:

you have 2 options:

  • via ssh (You will upload code with your SSH KEY configured in Git)
  • via https (It will ask you for your Git user username and password)

You can see that it is configured correctly:

git remote -v

If you choose ssh, you must add your ssh-keys to the remote repository.

Type

 git push -u origin main

to push your changes to the remote repository

Before pushing you must do git add . and git commit -m “first commit”

In Gitlab, you must remove the branch protection and force push rules.