Skip to content

App tutorials

3 min read

How to Push to GitLab

By Khamosh Pathak · June 10, 2019
how-to-push-to-gitlab primary img

To get started with GitLab, you'll need to create a repository and push code to it. Here's how to push to GitLab.

How to Create a Project (Repository) in GitLab

Because of their larger potential in GitLab, repositories are called projects. But you can use the words interchangeably because a project behaves the same way as a repository you might find on GitHub.

After creating your account in GitLab, go to your Projects page and click New project.

Blank project page in GitLab

From the Blank project tab, give the project a name and add a description. If you want it to be a public repository, click the Public option. Make sure the Initialize repository with README option is left unchecked. Then click the Create project button.

How to Push to GitLab

Once a new project is created, it will be blank by default. There are a couple of ways to populate it. You can directly add files online using the Add Files button.

But if you're going to be using GitLab as an online versioning tool, it's best to upload your local project files using the command line. To get started, first install and set up Git on your Linux, Mac, or Windows PC.

Then, open the Terminal (Git Bash on Windows) and navigate to the local folder that you want to sync with your GitLab project. Use the cd command to switch to the folder in question.

Now you can start the Git process with this command:

git init

git init

Now you'll connect the remote GitLab project with your local directory. Use the following command, pasting in your GitLab project URL at the end (make sure it ends in .git).

git remote add origin <project link>

git remote add origin

After you press Enter or Return, you won't see any confirmation. That's because you haven't added or transferred the files to the Git process yet. To add all the files from the current directory to the Git process, use the following command.

git add .

Then you can check if all files were added correctly using the following command.

git status

git status check

Now you'll make a commit, so you know which files were included when the local directory was first uploaded to the GitLab project. You can add your comment between the quotes at the end of the next command. It can include what changes you made recently to the code and if you added any new files.

git commit -m "first commit"

first commit

Now you're ready to actually push the files and code to GitLab. Enter the following command.

git push -u origin master

origin master

After you press Enter or Return, you'll be asked to enter your GitLab username and password. Since you've created a private repository, this step makes sure that only the project owner can make changes to the repository.

Once the authentication is done, the upload process will begin. And shortly, you'll see a message saying that the upload is finished.

To check whether all the data was uploaded properly, you can open the project in your browser. Instead of the blank page, you'll now see a list of all the files and folders in the project.

alt

Automate GitLab with Zapier

Zapier lets you connect GitLab to thousands of apps, so you can automate more of your Git processes.

  • For example, you could automatically get a notification or create a task in your project management tool whenever there's a new merge request in your repo.

Post new GitLab merge requests to Slack channels

  • GitLab logo
  • Slack logo
GitLab + Slack
More details
    Do you currently ping your team whenever you have a new merge request in GitLab? Let Zapier do the notifying for you. This integration will post the merge request to a Slack channel so your team can act on the request quickly and you can keep working.

    Send emails with Gmail for new GitLab merge requests

    • GitLab logo
    • Gmail logo
    GitLab + Gmail
    More details
      Do you often send merge requests to the same contacts every time? Stop wasting time and let Zapier do it for you! Use this integration to send an email via Gmail whenever a new merge request is submitted through GitLab.

      Post new GitLab merge requests to Twist

      • GitLab logo
      • Twist logo
      GitLab + Twist
      More details
        When you're working on projects and knocking out issues, it can be difficult to always remember to submit merge requests to your team. Once activated, this integration will automatically post your GitLab merge requests to Twist. That way, Zapier will handle it for you and you can continue working on issues.
        • Or you could create a new issue in GitLab whenever you get a relevant email or move a Trello card to a specific status.

        Create GitLab issues from starred Gmail emails [Business Gmail Accounts Only]

        • Gmail logo
        • GitLab logo
        Gmail + GitLab
        More details
          Throughout the day you're likely getting emails from colleagues and some of those emails probably need development work. Set up this integration and Zapier will automatically create a new issue in GitLab for starred emails in Gmail.

          Create new GitLab issues from inbound emails

          • Email by Zapier logo
          • GitLab logo
          Email by Zapier + GitLab
          More details
            Are you getting a lot of emails from colleagues about bugs or issues that need development work? Use this Email by Zapier integration so that any emails forwarded to a specified email address will automatically have an issue created for them in GitLab.

            Add Trello cards to create new GitLab issues

            • Trello logo
            • GitLab logo
            Trello + GitLab
            More details
              Do your various teams use different tools? Wouldn't it be ideal if those tools could communicate behind the scenes? Once configured, this integration will automatically create new issues in GitLab whenever a card is added to a Trello board or moved to a specific list. Now your sales, support or marketing team can create issues for your development team while staying in the tools they know best.

              Head to our GitLab integrations page for more ideas on how to supercharge GitLab.

              Get productivity tips delivered straight to your inbox

              We’ll email you 1-3 times per week—and never share your information.

              Related articles

              Improve your productivity automatically. Use Zapier to get your apps working together.

              A Zap with the trigger 'When I get a new lead from Facebook,' and the action 'Notify my team in Slack'