How to push project source code to Gitlab ?

Sour LeangChhean
2 min readJan 11, 2023
Photo by Pankaj Patel on Unsplash

To push a project to GitLab, you will first need to create a repository for the project on GitLab. Once you have created the repository, you can follow these steps to push your local project to the remote repository on GitLab:

  1. Initialize a local Git repository for your project, if you haven’t already done so. Run git init in the root directory of your project.
  2. Add the remote GitLab repository as a remote for your local repository. Run git remote add origin git@gitlab.com:username/repo.git, replacing "username" and "repo" with your GitLab username and the name of the repository you created on GitLab.
  3. Add the files in your project to the local Git repository. Run git add . to add all files in the current directory and subdirectories, or git add <file> to add specific files.
  4. Commit the added files to the local repository with a commit message. Run git commit -m "Initial commit" or your own commit message
  5. Push the local repository to the remote repository on GitLab. Run git push -u origin master

This will push the master branch of your local repository to the remote repository on GitLab, and the remote will be set as the default upstream repository, so you can use the command git push in the future

Please note that the above command is git bash command, if you are using some other client you may use their respective command. Also this is general instruction, some slight changes might be required as per the organization setup.

--

--