The Need to Simultaneously Commit

With the increase in the number of version control tools, there has been an increasing hassle on not only using the VCSs but also switching back and forth between the VCSs (Version Control Systems). Managing more than one is just tedious. I am going to walk you through working with more than one VCS tool, most especially committing, and those two include GitHub and GitLab. I took my time to try to understand how as a Developer, I could commit my changes to both the version control tools, all
within the same project, and here is what I came up with:

What you'll require

So let's begin:

Firstly, we'll will have to create accounts for the tools we are going to use if you already haven't signed up. I have included links where you can sign up for the VCSs that we are going to use and they include:

  1. Github
  2. Gitlab

(For convenience, I would recommend using the same password for both, but for security, I would recommend having separate passwords for each.).

Secondly, Ensure your project is hosted on GitHub remotely. Here is a link with the instructions on how to add a new project on GitHub: Adding a project on GitHub

Thirdly, head over to GitLab and Open your GitLab account. Here is a link with instructions that will guide you to importing your project on GitLab: Importing your Project on Gitlab

You can create a new project. However, we are going to import the project from GitHub, so choose the import project tab instead:

choose the import project tab instead:

Next, choose import project from GitHub:

import project from GitHub:

You will then be required to authenticate using GitHub, click the authenticate using GitHub Button that will take you to an external link to GitHub where you will require to sign in with GitHub if you already haven't:

 require to sign in with GitHub

You will then have to choose the project repository you want to import:

!You will then have to choose the project repository you want to import:

When you have successfully imported the project, you should see the project as follows:

When you have successfully imported the project, you should see the project as follows:

Committing to GitHub and GitLab: The Command Line way

After having your projects imported on both GitHub and GitLab, we can now start learning how to commit a project on both VCSs.

  1. Navigate to the project and open it in your terminal (For Windows users, that’s the CMD - Command Prompt).

    Navigate to the project and open it in your terminal

  2. Copy the project URL in GitHub first and run the following command:

    git remote set-url origin --push --add https://github.com/[username]/[project_name]

    Copy the project URL in GitHub first and run the command

    [username] is your username on GitHub
    [project_name] is the name of the repository on GitHub

  3. Copy the project url in GitLab and run the following command:

    git remote set-url origin --push --add https://gitlab.com/[username]/[repository-name]

    Copy the project url in gitlab  and run the command

    [username] is your username on Gitlab
    [project_name] is the name of the repository on GitLab

    (you have to note that the two URLs look alike but the domain names are different, one belongs to GitHub and the other GitLab)

  4. We have to push our changes from our local repository to the remote repositories on our Version Control Systems.

     We have to push our changes from our local repository to the remote repositories on our Version Control Systems.

    If you have no proper knowledge of pushing changes to git, you can check out this help guide from GitHub here

  5. Will use git status to check my changes:

    Will use git status to check my changes

  6. Followed by git add . to add project to local

    Followed by git add .  to add project to local

  7. Commit your changes including a commit message that doesn't exceed 50 characters. (It's always a good practice to do so)

    git commit -m “gitlabgithabtutorial”

    Commit your changes including a commit message

  8. Finally push your changes:

    git push origin master

    Finally push your changes:

    (I have used master as my branch as it’s the only branch in my project)

    It Will first request your GitHub username and password as it was the first URL you enter

  9. After entering it will request your GitLab username and password

    After entering it will request your GitLab username and password

    It should then push the changes to Gitlab and Github, hassle free.

After successfully push, you should see the Remotely made changes on GitHub:

After successfully push, you should see the Remotely made changes on GitHub:

The same changes should also appear on GitLab:

The same changes should also appear on GitLab:

Now that's all for simultaneously commiting to GitHub and GitLab.

See you around!