Git introduction

What is git?

What is git

  • Git is a version control system used to track changes in code during software development.

  • It maintains a history of changes, enabling developers to revert to previous versions if necessary.

  • How git works

Git / Github / Gitlab
  • GitHub and GitLab are web-based platforms that provide Git repository hosting services, along with additional features for project management and collaboration.
    • There are many comparisons available online, e.g. here
    • You could choose one for yourself / stick to the one of your organization / use both depending on the project
    • An analogy: Dropbox vs Google Drive
Why use git?

Why use git

  • History tracking:

    • Git maintains a detailed history of changes, allowing you to revert to previous versions of your code if something goes wrong.
      center
Why use git?

  • Backup: You ensure that your work is backed up
  • Reusability: You always have access to your code, making it easier to find and reuse pieces from your previous projects.
Why use git?

  • Centralized location of your code:
    • Access your code from anywhere - ideal for workflows where development happens locally but deployment or testing occurs on remote servers.
  • Enchanced collaboration:
    • Git enables multiple developers to work on the same project simultaneously without interfering with each other's work.
  • Project management:
    • Platforms like GitHub and GitLab offer additional tools for issue tracking, project management, and code reviews, making it easier to manage and collaborate on projects.
Basic concepts: How it works

How it works

  • Your repository is a miniature filesystem
  • Every commit is a “snapshot” of that system
    • Each commit saves a “snapshot” of all files at that moment. If files haven't changed, Git simply “skips” them.

Basic concepts: How it works

  • Your repository is a miniature filesystem
  • Every commit is a “snapshot” of that system
    • Each commit saves a “snapshot” of all files at that moment. If files haven't changed, Git simply “skips” them.

Basic concepts: Standard workflow

Standard workflow

  • Make changes →git add path/to/changed/filesgit commitgit push:
    center
Basic concepts: Standard workflow

  • Make changes →git add path/to/changed/filesgit commitgit push:
    center
Basic concepts: Standard workflow

  • Make changes →git add path/to/changed/filesgit commitgit push:
    center
Basic concepts: Standard workflow

  • Make changes →git add path/to/changed/filesgit commitgit push:
    center
Basic concepts: Standard workflow

  • Make changes →git add path/to/changed/filesgit commitgit push:
    center
Basic concepts: Standard workflow

  • Make changes →git add path/to/changed/filesgit commitgit push:
    center
Basic concepts: Standard workflow

💡 Other local repositories need to be updated in order to have the same version as remote repository:

  • In another cloned repository: git pull

    center

Basic concepts: Standard workflow

💡 Other local repositories need to be updated in order to have the same version as remote repository:

  • In another cloned repository: git pull

    center

Basic concepts: Standard workflow

💡 Other local repositories need to be updated in order to have the same version as remote repository:

  • In another cloned repository: git pull

    center

Basic concepts: Standard workflow

💡 Other local repositories need to be updated in order to have the same version as remote repository:

  • In another cloned repository: git pull

    center

Basic concepts: Standard workflow

💡 Other local repositories need to be updated in order to have the same version as remote repository:

  • In another cloned repository: git pull

    center

Basic concepts: Standard workflow

💡 Other local repositories need to be updated in order to have the same version as remote repository:

  • In another cloned repository: git pull

    center

Basic concepts: Standard workflow

💡 Other local repositories need to be updated in order to have the same version as remote repository:

  • In another cloned repository: git pull

    center

Basic concepts: Standard workflow

💡 Other local repositories need to be updated in order to have the same version as remote repository:

  • In another cloned repository: git pull

    center

Explanation of git commands

Explanation of git commands

  • git add:
    • a command you use to add changes into the git staging area. You could think of it as a command to tell the system changes in which files you want to save and upload globally.

      💡 Git staging area is a space where changes are collected and reviewed before they are committed to the repository.

  • git commit -m "[a short explanation of changes]":
    • a command to save changed files to the local repository. It records a snapshot of the project’s currently staged changes.
  • git push:
    • a command to upload commits from a local computer to a remote git repository.
Explanation of git commands

Supermarket analogy for Git commands

center

Explanation of git commands

Supermarket analogy for Git commands

center

Explanation of git commands

Supermarket analogy for Git commands

center

Explanation of git commands

Supermarket analogy for Git commands

center

Explanation of git commands

Supermarket analogy for Git commands

center

Explanation of git commands

Supermarket analogy for Git commands

center

Explanation of git commands

Supermarket analogy for Git commands

center

Explanation of git commands

Supermarket analogy for Git commands

center

Explanation of git commands

What happens when you create multiple commits but don't push them?

center

Explanation of git commands

What happens when you create multiple commits but don't push them?

center

Explanation of git commands

What happens when you create multiple commits but don't push them?

center

Explanation of git commands

What happens when you create multiple commits but don't push them?

center

Explanation of git commands

What happens when you create multiple commits but don't push them?

center

Explanation of git commands

What happens when you create multiple commits but don't push them?

center

Explanation of git commands

What happens when you create multiple commits but don't push them?

center

Explanation of git commands

What happens when you create multiple commits but don't push them?

center