How to upload project from local file system to GitLab

Viewed 6472

I have locally developed an application using Laravel Framework and PhpStorm. So, in the file system of my pc I have the project that I want to upload in a repository created in GitLab.

I have to mention that for development purposes I am currently using Homestead in windows with Vagrant virtual machine.

I already have an account in GitLab and for now I have only created a README file.

What are the necessary steps in order to upload my project in GitLab?

2 Answers

you can create new project without Initialize repository with a README file.

and follow "Push an existing folder" look like:

Push an existing folder

cd existing_folder
git init --initial-branch=main
git remote add origin git@gitlab.com:youraccount/project_name.git
git add .
git commit -m "Initial commit"
git push -u origin main
  1. You have to create a new repository. Use the following command to create an a Git repository. It can be used to convert an existing, unversioned project to a Git repository or initialize a new, empty repository. A .git folder is created in your directory. This folder contains Git records and configuration files. You should not edit these files directly.
git init
  1. If you want to add the files to track with git then you need to usegit add command. if you want to add new or modified or deleted files in the current directory. then add . to select all the files.
git add .
  1. git commit creates a snapshot of the changes made to a Git repository which can then be pushed to the main repository. The -m option of the commit command lets you write the commit message.
git commit -m "first commit"
  1. You add a “remote” to tell Git which remote repository in GitLab is tied to the specific local folder on your computer. The remote tells Git where to push or pull from. You have to create a project to hold your files. You should create a project in gitlab.that path should be given in the following command.
git remote add origin git@gitlab.com:username/projectpath.git
  1. Get the changes from the remote with git pull
git pull origin master
  1. Push the commits to the GitLab project
git push origin master

If any problem occurs in pushing use the following command for force push git push --force origin master

Related