How to sync up new Git repository on GitHub or GitLab

From time to time you necessary to set up new Git repository. This article is about a list of commands which are helpful for creating a new repository and syncing it with GitHub or GitLab.

This article focuses only on users with Mac or Linux. For creating new repository or pairing existing with GitHub account or custom GitLab on Windows, please visit official tutorial at GitHub website.

 

Setting global git config credentials

First of all, we need to be sure that we have set global config information. This is one-time configuration.

Creating the new repository and pushing new it to GitHub or GitLab

This is the short list of terminal commands for creating a new local repository and syncing the changes with GitHub or GitLab repository.

Repository SSH link can be found at GitHub or GitLab project landing page or quick setup page.

Copy/Clone existing GitHub or GitLab repository to local folder

This is the short list of terminal commands for cloning existing GitHub or GitLab repository to local repository.

Cloning the repository does not make automatically git repository. For that, we need to repeat the step (above) of initializing local Git repository and setting the origin repository on GitHub or GitLab.

Security reminder

Never git add, commitpush sensitive information (like passwords, keys, configs, credit card numbers PINs and numbers, etc.) to your remote repository.