Skip to content

Setting up git

Note

All information provided in this page comes from here

Make an account

MDEF Only

  • Make an account in Github.com using the email you used in the program registration form

Format for the username

Make a username as such: name_surname

For example if my name is…

Andrés López Lee Peters: andres_lopez

Or…

Wongsathon Choonhavan: wongsathon_choonhavan

Go local

  • In your terminal, add your Git username and set your email

git config --global user.name "your_username"

  • Configure you email address for uploading

git config --global user.email "your_email@mail.com"

Generate SSH Keys

  • Check if you have an SSH KEY already (If you see a long string starting with ssh-rsa, you can skip the ssh-keygen step):

cat ~/.ssh/id_rsa.pub

  • Generate your SSH key:

ssh-keygen -t rsa -C "your_email@mail.com"

  • Now let´s see your keygen

cat ~/.ssh/id_rsa.pub

  • Copy your key:

Windows

clip < ~/.ssh/id_rsa.pub

macOS

pbcopy < ~/.ssh/id_rsa.pub

linux

xclip -sel clip < ~/.ssh/id_rsa.pub

Go global

Add the copied key to github.com by following this guide

Make a repository

There are several ways to have a repository:

  • In the online git platform, create a repository and then clone it
  • In your terminal initialising it from scratch
  • Cloning an existing one (most likely)

Online Git platform

If you are using and online web service for git (Github, Gitlab, bitbucket…), you can create a new project or repo by simply going to one of these below and then follow the instructions to clone it:

Terminal from scratch

Step-by-step

  • Navigate to the folder where you want to put or create your repo

  • In the terminal, type:

git init

  • If you have a remote already, you can just do:

git remote add origin git@github.com:gitusername/repository.git

  • And then pull the remote:

git pull

Cloning an existing one

If you have a template or an online repository you want to reuse, you can navigate with your terminal to the desired destination folder and do:

MDEF Students

  • Navigate to the folder where you want to put or create your repo

    cd folder-for-your-project

  • Clone your student repository (ssh)

    git clone git@github.com:fablabbcn/mdef-template.git

  • Create your own project in Github - Direct access - Make sure that is public!!

  • Tell your local repository to push to the new project in Github:

git remote rename origin old-origin git remote add origin git@github.com:username/your-repo-name.git

  • Do some edits and then add-commit-push (like this for the first commit):

git add FILENAME git commit -m "My first commit" git push -u origin --all

  • For further changes, your workflow should be:

git add FILENAME git commit -m "My other commit" git push

About the commit message

This is a general point of failure for many many students (and instructors) that do not make a relevant commit message.

Write a meaningful commit message. This should answer the question:

“If I apply this commit, I will… “.

For example:

“uploading final project idea”

This is not OK at all and will not help anyone to trace problems (and they will happen):