How to Push an Existing Project to GitLab |Video upload date:  · Duration: PT19M14S  · Language: EN

Step by step guide to push an existing local project to GitLab using remote setup SSH or HTTPS and branch configuration

So you built something locally and now you want to shove it up to GitLab where other humans can stare at your code. This guide will get your repo initialized linked to a remote and authenticated so pushes do not fail in dramatic ways.

Prepare the local repository

Initialize and commit

If your folder is not a git repo yet start it. Keep a sensible .gitignore so secrets do not go viral.

git init
git add .
git commit -m "Initial commit"

Check the basics

Make sure your branch name is what you expect. Many repos use main now but your project might still use master or something quirky.

Create a project on GitLab and copy the remote URL

On the GitLab web interface create a new project. Copy the remote URL that GitLab shows under repository settings. Do not type that long string by hand unless you enjoy debugging typos at 2 a m.

Add the remote and push a branch

Link your local repo to the GitLab remote using a placeholder instead of an actual URL when documenting steps.

git remote add origin GITLAB_REMOTE_URL
git push -u origin main

The -u flag sets the upstream so future pushes are simpler and less likely to trigger a panic.

Authentication options

SSH keys

SSH keys are the convenient and secure option. Generate a key pair and paste the public key into your GitLab profile under SSH keys.

ssh-keygen -t ed25519 -C "your@example.com"
# then copy the public key file and paste it into GitLab

Test the connection with a simple fetch or an ssh test command to verify GitLab recognizes your key.

Personal access token

If you prefer HTTPS or need CI friendly credentials create a personal access token in GitLab with repository scopes. Use that token as the password when git prompts you, or configure a credential helper to cache it so you do not paste it every time.

git config --global credential.helper cache
# when prompted for a password while using an HTTPS remote provide your personal access token

Verify the remote and manage branches

  • Confirm the remote URL with git remote -v.
  • See all branches with git branch -a.
  • Push other branches with git push -u origin branch-name.

You now know how to initialize a repo add a GitLab remote configure authentication and push branches without summoning the ancient error messages. Go forth and commit with slightly more confidence and slightly less regret.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.