Skip to content

- Gitlab

1. What is a version control system?

  • Able to keep track of changes made to a file
  • Able to share change file history.
  • Able to restore a state to a point in time in the past and display the differences in the changes.

2. Learn Git tutorial

I learned about 2 following tutorials
- Git Simple Cheat Sheet on fabcloud tutorials
- GitLab_tutorials_(Japanese) that fablab Kamakura made.

Then, I start to making my site.

3. Setup Git (to do only the first time)

3-1) Install Git

Git is usually preinstalled on Mac, so I input command line on Terminal.

git --version

As result, my PC has "git version 2.37.1 (Apple Git-137.1)" so, move to next step.

3-2) Identify user

git config –-global user.name “YOUR_USERNAME”
git config -–global user.email “xxxxxxxx@xxxxx.com”

NOTE:
I input git account username and user.email.

3-3) Set the SSH key

Open Terminal and type as following.

ssh-keygen -t rsa -C "xxxxxxxx@xxxxx.com"

NOTE:
I typed my cloud address for “xxxxxxxx@xxxxx.com” for git.
Then, appeared below phrase that Specify where to save the SSH key.

Enter file in which to save the key:

NOTE:
- The SSH key is stored in the .ssh folder.
- The .ssh folder (default) is under your home directory (C:\Users/username/.ssh in Window; /Users/username/.ssh in Mac), as tutorials.

Then, appeared below phrase, Enter my passphrase.

Enter passphrase (empty for no passphrase)
Enter same passphrase again;

NOTE:
- The passphrase is using "remote repository" and "local repository" connect
- to be secret, I should remind it in my mind only.

Then I want to change directly to default .ssh folder (/Users/username/.ssh)for mac to confirm the rsa.pub is there. Then I find it.

Then Enter the command to display the contents of id_rsa.pub in order to see the SSH key

cat id_rsa.pub

As I see a SSH key on the terminal, so I copy it. FYI, the contents of the SSH key will begin with ssh-rsa and end with the email address. The SSH key is only for me, so I can't show.

ssh-rsa ~~~~

...

~~~  xxxxxxxx@xxxxx.com

3-4) Register SSH key to Gitlub

Going to GitLab > User icon on the right top corner > Profile edit

ssh1

Then, click SSH key on the left side, and Paste the SSH key.

ssh2

3-5) Exclude .DS_Store from commit (for mac M1)

Create a .gitignore file under the local repository.
Then, Write .DS_Store in the .gitignore file.

What is .DS_Store?: hidden file create in Mac when operating finder.
useful links: blog by Code club 965 (Japanese) Sorry I only find in Japanese


4. Copy my remote Repository (to do only the first time)

I bring (clone) the contents of a remote repository, do the following. The source address (git@~) is obtained from the remote repository (Gitlab project page). I do this only the first time, except I miss something.

git clone git@xxx.xxxxx

clonewithssh


5. Codes when upload file to remote repository (at least)

Update the newest data to local (If the project join only me not necessary)

git pull

Check the add

git status

Add the changes

git add .

Commit(add) the update to the local repository, briefly describing the update in XXXX (in English)

git commit -m "XXXX"

Update to Remote repository

git push