intro-frontend-course

Getting Started with Git and GitHub

Objective: By the end of this lesson, you will understand the importance of version control, know how to install Git, sign up for a GitHub account, and perform basic Git operations.

What is Version Control?

Version control is an essential tool for developers to track changes in their code, collaborate with others, and revert to previous versions if needed. It allows you to manage changes to a project over time, keep a history of those changes, and collaborate with others seamlessly.

Key Benefits:

What is Git?

Git is a popular version control system that allows developers to efficiently manage project versions. It is widely used in the industry for its robustness and distributed nature, which means every developer has the full history of the project on their local machine.

What is GitHub?

GitHub is a web-based platform that uses Git for version control. It provides a user-friendly interface to manage Git repositories, collaborate on projects, and share code with others.

Other Version Control Tools

While Git and GitHub will be the main tools used in this course, it’s important to be aware of other version control systems:

Installing Git

For Windows:

  1. Visit Git for Windows and download the installer.
  2. Run the installer and follow the setup instructions.

For Mac:

  1. Download the installer from Git for macOS.
  2. Follow the installation instructions.

For Linux:

  1. Open a terminal.
  2. Install Git using your package manager. For example:
    sudo apt-get install git
    

Setting Up Git

After installing Git, configure your Git environment with your name and email:

git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
git config --global color.ui auto

Opening a GitHub Account

  1. Visit GitHub and sign up for a free account.
  2. Follow the instructions to create your profile.

Creating a Repository on GitHub

  1. Log into your GitHub account.
  2. Click the ‘+’ icon in the top right corner and select ‘New repository’.
  3. Name your repository, add a description, choose public/private, and optionally initialize with a README.
  4. Click ‘Create repository’.

Creating a Local Repository

  1. Choose or create a directory on your computer where you want the project to reside.
  2. Open a terminal and navigate to this directory.
  3. Run the following command to initialize a Git repository:
    git init
    

Adding and Updating Remotes

Adding a Remote: Link your local repository to your GitHub repository:

git remote add origin [URL of your GitHub repo]

Replace [URL of your GitHub repo] with the actual URL.

Changing a Remote’s URL: If you need to update the URL:

git remote set-url origin [New URL of your GitHub repo]

Pushing Changes to GitHub: After making changes to your local repository, push them to GitHub:

git add .
git commit -m "Initial commit"
git push -u origin master

Key Lesson Concepts: