How to push code to gitlab

In this article let’s discuss about How to push code to gitlab. Let’s go through the following methods without any delay.

Method 1:

cd existing_repo
git init
git remote add origin https://gitlab.com/your_account_name/project_name.git
git branch -M main
git add .
git commit -m "Initial commit"
git push -uf origin main

If you are facing any issues with the above approach then try the alternative that is given below. It may look similar by have a try!

Method 2 :

## Git push using SSH
git push --set-upstream git@gitlab.example.com:namespace/nonexistent-project.git master

## Git push using HTTPS
git push --set-upstream https://gitlab.example.com/namespace/nonexistent-project.git master

Hope the above solution works.

Realted Posts : How to create zip file ubuntu