Git & GitHub Basics

Git, GitHub, Version Control, Collaboration

Main project image

Introduction

Git and GitHub are essential tools for any programmer. Git is a version control system that allows you to track changes to your code, while GitHub is a platform for hosting and collaborating on Git repositories. This guide will walk you through the basics of using Git and GitHub.

Installing Git

First, you need to install Git on your computer. You can download the appropriate version for your operating system from the official Git website. Follow the installation instructions for your system.

Basic Git Commands

Here are some basic Git commands you’ll use frequently:

Creating a GitHub Repository

  1. Go to GitHub and sign up for an account if you don’t already have one.
  2. Click the ”+” button in the top right corner and select “New repository”.
  3. Give your repository a name and description.
  4. Choose whether to make the repository public or private.
  5. You can initialize the repository with a README file, if you wish.
  6. Click “Create repository”.

Connecting Git to GitHub

Once you have a GitHub repository, you can connect it to your local Git repository:

  1. In your local repository, run:
    git remote add origin <repository_url>
    Replace <repository_url> with the URL of your GitHub repository.
  2. To push your local commits to GitHub, use:
    git push -u origin main

Collaboration with GitHub

GitHub provides features for collaboration, such as:

Conclusion

Git and GitHub are powerful tools that can greatly improve your workflow and collaboration with others. This guide provides a basic introduction, but there’s much more to explore. Refer to the official Git documentation and the GitHub documentation for more information.