Introduction to git and github

Introduction to git and GitHub


 

Miguel Xochicale, PhD
Zakaria Senousy, PhD
mxochicale/{intro-to-git-and-github}

Overview

  1. Automated Version Control
  2. Git and GitHub
  3. Exercises
  4. References

Automated Version Control (AVC)

Automated Version Control (AVC)

  • A system that automatically manages changes to files, typically in the context of software development.
  • Keeps track of every modification to the code in a special kind of database.
  • If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimising disruption to all team members.

AVC: What should I care?

AVC: What should I care?

Automated Version Control

  • Backup and restore: Changes are stored securely and can be restored at any point.
  • Collaboration: Multiple people can work on the same project at the same time.
  • Track changes: You can see who last modified something that might be causing a problem, who introduced an issue, when it was introduced, and more.
  • Explore alternatives: Safely experiment with new ideas in a branch, without affecting the main project.

Introduction to Git and GitHub

  • Git: A version control system that lets you manage and keep track of your source code history.
  • GitHub: A cloud-based hosting service that lets you manage Git repositories.
  • Benefits:
    • Track changes in your code across versions.
    • Collaborate with others on projects.
    • Backup your work on the cloud.

Git command Basics

  • Installation:
  • Configuration:
    • Set your user name: git config --global user.name "Your Name"
    • Set your email: git config --global user.email "your.email@example.com"

  • Initialise a New Repo:
    • git init
  • Cloning an Existing Repo:
    • git clone https://github.com/username/repository.git

Git command Basics

  • Track Changes:
    • git status
    • git add <file>
  • Commit Changes:
    • git commit -m "Commit message"

  • Using Git Pull:
    • git pull origin master
    • This command pulls changes from the remote repository and merges them into your local branch.

  • Connect to Remote Repo:
    • git remote add origin https://github.com/username/repository.git
  • Push Changes:
    • git push origin master

Other Useful Git Commands

  • git branch: List, create, or delete branches.
  • git switch <branch>: Switch branches.

  • git log: Display commit logs.
  • git diff: Show file differences not yet staged.

  • git rebase: Reapply commits on top of another base tip.

Git data transport commands

GitHub workflow

GitHub workflow

Exercises

🥑 How to Make the Best Guacamole?

  • Create SSH keys
  • git clone git@github.com:mxochicale/intro-to-git-and-github.git
  • Raise a new issue with the tamplate How to Make the Best Guacamole?

References