GitHub Tutorial
Written By: Avinash Malhotra
GitHub is a web-based Git repository hosting service. It offers all of Git's functionality plus additional features like issue tracking, pull requests, and collaboration tools.
GitHub is one of the most important tools for developers today. It helps you store code, collaborate with others, and even host websites.
In this guide, you'll learn:
- How to create a GitHub account
- How to use GitHub basics
- How to create and upload repositories
- How to create GitHub Pages (host your website for free)
What is GitHub?
GitHub is a cloud platform built on top of Git (a version control system). Github is owned by Microsoft. Github also own npm (Node Package Manager).
What is Git?
Git is a distributed version control system that allows you to track changes in your code over time.
For example, if you have a project with multiple files and you want to keep track of all the changes you make, you can use Git.
Git allows you to save different versions of your code, so you can go back to any previous version if needed. It also helps you collaborate with other developers by allowing you to merge changes from different people.
👉 In simple words:
- Git = tracks changes in your code
- GitHub = stores your code online + helps you collaborate
To Install Git, click link 👉 : Install Git
Create Github Account
To create a GitHub account, follow these steps:
- Go to github.com
- Click on the "Sign up" button
- Fill in the required information
- Verify your email address
Once you have created your account, you can start using GitHub to store and manage your code.
It is recommended to use a strong password and enable two-factor authentication for your GitHub account.
Understanding Github Dashboard
The GitHub dashboard is the main interface where you can manage your repositories, view notifications, and access various features of GitHub.
The dashboard is divided into several sections:
- Repositories: This section shows all the repositories you have created or contributed to.
- Issues: This section allows you to track and manage issues related to your repositories.
- Pull Requests: This section allows you to review and merge pull requests from other contributors.
- Actions: This section allows you to automate workflows for your repositories using GitHub Actions.
- Projects: This section allows you to organize and manage your work using project boards.
The dashboard also provides access to your profile settings, notifications, and other GitHub features.
Create Repository
A repository is a location where all the files for your project are stored. Its is a part of project management. Consider repository like a folder of your project. It can be a whole project or just a part of it.
To create a new repository on GitHub, follow these steps:
- Go to your GitHub dashboard
- Click on the "New" button next to "Repositories"
- Fill in the repository name and description
- Choose the repository visibility (public or private)
- Click on the "Create repository" button
Once you have created your repository, you can start adding files and collaborating with others.
Upload Code in Repository
To upload code to your GitHub repository, you can use the following methods:
Using Github Web Interface
Using GitHub Web Interface: You can also upload files directly through the GitHub web interface. Go to your repository, click on the "Add file" button, and select "Upload files". Then, you can drag and drop your files or choose them from your computer to upload them to GitHub.
Github Web Interface is recommended for beginners.
Using Github Desktop
Using GitHub Desktop: GitHub Desktop is a graphical user interface that allows you to manage your repositories and upload code without using the command line. You can simply drag and drop your files into the GitHub Desktop application and it will handle the rest.
Using Git Command Line
Using Git Command Line: You can use Git commands to upload your code to GitHub. First, you need to initialize a Git repository in your project folder, add your files, commit the changes, and then push the code to GitHub.
After uploading your code, you can manage it using GitHub's features such as branches, pull requests, and issues to collaborate with other developers.
Update Code ( Push Changes )
To update code in your GitHub repository, you can use the following methods:
Using Github Web Interface
Using GitHub Web Interface: You can edit files directly through the GitHub web interface. Go to your repository, navigate to the file you want to edit, click on the pencil icon to edit the file, make your changes, and then commit the changes to update the code in your repository.
Using Git Command Line
Using Git Command Line: You can use Git commands to update your code in GitHub. First, you need to pull the latest changes from the repository, make your changes locally, commit the changes, and then push the updated code back to GitHub.
After updating your code, you can manage it using GitHub's features such as branches, pull requests, and issues to collaborate with other developers.
Create Github Pages
GitHub Pages is a free hosting service provided by GitHub that allows you to host static websites directly from your GitHub repositories. You can use GitHub Pages to create personal blogs, project documentation, or any other static website.
To create a GitHub Pages site, follow these steps:
- Go to your GitHub repository
- Click on the "Settings" tab
- Scroll down to the "GitHub Pages" section
- Choose the source for your GitHub Pages (e.g., main branch or a specific folder)
- Click on the "Save" button
Once you have set up GitHub Pages, your website will be available at a URL like https://your-username.github.io/repo-name/. You can customize your website by adding HTML, CSS, and JavaScript files to your repository.