You will need
Go to GitLab website and log in. If you don’t have an account yet, sign up with your credentials. Alternatively, you can sign in with Google, LinkedIn, and other third-party sites.
Press “Create a project”, then “Create blank project”. Put in your project’s name (we use “Test”) and a slug (for example, “test”). The slug will show up in the URL of your project on GitLab. Optionally, fill in a project description. Note: By default, the visibility of your project is private. You can change it to “public” if your project is public-facing and the code doesn’t contain any sensitive data. We changed visibility from “Private” to “Public” in this example.
After completing these steps, your repository will open.Here you can see the “Test” repository is empty and has only a couple of default files: a README with basic user documentation and a GitLab yml file for continuous integration. Learn more about the yml file here.
Use the following commands for git configuration in your terminal on Mac and Linux or in Git Bash on Windows.
git config --global user. name <give username>
git config --global user.email <your email>
Note: Skip this step you are not a new user and already have this configured.
Make a directory/folder using the following command:
mkdir <your foldername>.
Open your newly created directory/folder with
cd <folder name>.
Confirm the directory location with
Then initialize your git repository using
Create a text file called "input" using the touch command:
Open your file in the notepad using:
notepad <file name>.
As you type the
notepad <file name> command, the notepad will open, as shown on the screenshot. Type something into the file and save. The text we use for this example is "Hello, welcome to step-by-step guide on GitLab!!"
Check the current status of your git repository using the
git status command.
Add untracked files in the current directory to the staging area with
git add .
git commit -m <commit message>. Confirm everything worked by running
git status again.
Now use the remote command, followed by the push command, to push the file to the remote repository.
Input and run the following subsequent commands in your terminal:
git remote add origin <remote url>
git remote -v
Now push the local repository to remote GitLab server by using
git push -u origin main (you may need to change "main" to "master" depending on the name of the branch in GitLab).
As you write the push command, a Git Credential Manager window will pop up for authentication. Put in your GitLab credentials and confirm.
A local Git repository with changes pushed to a remote GitLab server.