getting started with git

I was inspired to write this after watching: EEVBlog2: LIVE HELP with Github/Gitlab on Youtube.

Preliminaries:

First ask yourself:

  1. Do I have a local folder (full of files and folders) that I want to put on Gitlab?
  2. Have I already created a repository on Gitlab?
    1. Did I create a “Readme” file on gitlab too?

There are two main ways to get your files on “Gitlab”.

This is a basic overview of the process:

If you are start a new project from afresh then the procedure is either:

A) start with a remote repository first.

This means you create the repository on Gitlab first, then clone it into a local folder.
On the local side this will do the following:

  1. create a new folder
  2. “change directory” to the newly created folder.
  3. initialise the local git repository.
  4. Add the remote repository.
  5. Pull the files from remote repository into the local one.

Commands you will need to run:
The default action of the “git clone” command is to clone the remote repository into a sub directory of 1) create a new folder. [linux] mkdir <FOLDER NAME or PATH> [Windows] MD <FOLDER NAME or PATH>the current directory, which is named the same as the remote repository.

1) create a new folder.
        [linux] mkdir <FOLDER NAME or PATH>
        [Windows] MD <FOLDER NAME or PATH>
   Skip to 2) if you already have a folder that you want to use.
2a) [Windows] <DRIVE LETTER>:
    [Windows] cd <FOLDER PATH>
2b) [Linux] cd <PATH TO FOLDER>
3) git clone username@host:/path/to/repository

OR

B) start with a local repository first.

This means you create the repository on your local PC first, then add your chosen Gitlab repository as a remote. Finally you push your local files from the local git repository to the remote one.

On the local side you will do the following:

    1) create a new folder.
        [linux] mkdir <FOLDER NAME or PATH>
        [Windows] MD <FOLDER NAME or PATH>
    2) "change directory" to the new folder.
        [Windows] cd <DRIVE LETTER>
        [Windows] cd <FOLDER PATH>
        [Linux] cd <FOLDER NAME or PATH>
    3) initialize the local git repository.
        git init
    4) Add the remote repository (Either chose an existing Gitlab repository or create a new one).
        git remote add origin username@host:/path/to/repository
    5) Pull the files from remote repository into the local one (if you have any files in the remote repository).
        git pull origin master