rlaplaza and crew at the IIQ in Seville

Git tips and tricks

Basic Git & GitHub Guide for Scientific Projects

About

This guide is for beginners who are new to Git and GitHub. It walks you through the process of setting up Git on your computer, creating a GitHub account, learning basic commands, and joining a GitHub organization (e.g., rlaplaza-lab).


Step 1: Create a GitHub Account

  1. Go to https://github.com
  2. Click Sign up
  3. Choose a username, enter your email, and create a secure password
  4. Verify your email and follow the on-screen instructions

Step 2: Install Git

On macOS

Use Homebrew:

brew install git

On Ubuntu/Debian

sudo apt update
sudo apt install git

On Windows

Download from the official site: https://git-scm.com/download/win

Follow the installer with default settings.


Step 3: Set Up Git

Open your terminal or Git Bash and configure Git with your name and email:

git config --global user.name "Your Full Name"
git config --global user.email "your@email.com"

You can check the configuration with:

git config --list

This allows you to securely connect to GitHub.

ssh-keygen -t ed25519 -C "your@email.com"

Then add your key to the SSH agent:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Copy your SSH public key:

cat ~/.ssh/id_ed25519.pub

Go to GitHub SSH settings, click “New SSH key”, and paste the key there.


Step 5: Request Access to rlaplaza-lab

  1. Contact Ruben and share your GitHub username
  2. They will invite you to the rlaplaza-lab GitHub organization
  3. Accept the invitation via email or at https://github.com/orgs/rlaplaza-lab

Step 6: Clone a Repository

Once you have access to a repository, you can clone it to your computer:

git clone git@github.com:rlaplaza-lab/project-name.git

Or with HTTPS:

git clone https://github.com/rlaplaza-lab/project-name.git

Step 7: Basic Git Commands

Check project status

git status

Add changes to staging

Staging is a temporary location that stores the changes you are going to do to the repository (kinda!). Adding changes to staging is necessary to let git know that the changes you made are things you want to change in the repo.

git add filename.py

Or add everything:

git add .

Commit changes with a message

A commit is a snapshot of the repository (kinda!). Once you have all the changes you want added (in staging), you make a commit with all those.

git commit -m "Describe your changes clearly"

Push changes to GitHub

Now, we can put our commit in the original repo (upstream branch).

git push

Pull latest changes from GitHub

We can also get the latest commit from the upstream branch. Of course, it is possible to change the branch we push and pull from, but we dont cover it here.

git pull

Step 8: Best Practices


Resources


Previous post
Coding tips and tricks
Next post
Writing tips and tricks