This tutorial explain the steps need to be followed to push a new local GIT Repository to GitLab.
What is GitLab?
GitLab is a single application that spans the entire software development lifecycle. GitLab is an open source project maintained by GitLab Inc with over 3,000 contributors. We can install and self-manage the GitLab Community Edition which is fully open source under an MIT license. GitLab also provides an Enterprise Edition that has additional features built upon the open source edition.
GitLab’s application offers functionality to collaboratively plan, build, secure, and deploy software as a complete DevOps Platform.
Steps to follow:
Step 1 – Login to GitLab using your username and password.
Step 2 – In the dashboard, click the blue New project button. This opens the New project page.
Step 3 – Select Create a blank project.
Step 4 – A new page will open. Provide the following information in that page:
- Project Name – Mention the name of your project in the Project name field – GitTest.
2. Project slug – When a name is added, the Project slug auto populates. This is the URL path for your project that the GitLab instance uses.
3. Project description (optional) – This field enables you to enter a description for your project’s dashboard, which helps others understand what your project is about.
4. Visibility Level – Select the appropriate Visibility Level for your project. I have selected private option.
5. I’m not checking ReadMe option as I already have a ReadMe file in my project.
Select the Create Project button.
We can see that a new empty project is created in the GitLab as shown below.
Step 5 – For every remote repo, you will get a unique URL as highlighted below. This URL is used to push the local changes to this remote repo. Type the below command in GitBash:
git remote add origin https://gitlab.com/vibhasingh2004/gittest.git
To open GitBash, go to the location where the project is saved and Right Click and Select GitBash Here.
Add remote URL to local GIT Repository
git remote command provide name to direct link to Repositories.
git remote command are used in conjunction with the git fetch, git push, and git pull commands.
git remote -v
This command list the remote connections we have to other repositories along with URL of each connection.
Push the local changes to a remote repo
To push the changes from GIT Local Repository to GitLab in particular branch of remote repo we need to use the below command:
git push <remote url or name> <branch name> git push origin master
origin is alias name of full GIT Repository path (https://gitlab.com/vibhasingh2004/gittest.git)
Now run the Git push command as shown above. It will ask for your Gitlab credentials in a new window as shown below. Please provide the username and password use to login to GitLab.
Now we can see we have successfully pushed the local changes to the remote repository. Lets go to GitLab and verify the latest changes. All the files from local GIT Repository are moved to GitLab Remote Repository.
I hope this tutorial has helped you to setup a new project in Gitlab and puch the local changes to GIT Remote Repository.