Introduction to GitHub

Issath Sesni
6 min readMay 16, 2021

--

We know GitHub is a website. It provides developers a cloud based service to store and manage their source code as well as track and control changes to their code. It is called code hosting platform. We want to look 2 principles to get a clear idea about GitHub.

  1. Version Control
  2. Git

Version Control

It is a system that tracking changes to a file over time, so that we can recall specific version of the file later. If a developer want to work on a specific part of the project, it is not safe to edit directly in the main project. In that case, version control steps in. It helps developers to work safely through branching and merging.

Branching :- Get a copy of the project. We can make changes without affecting to the main project.

Merging :- Once we have done the changes and that is acceptable by the project maintainer, then we merge our changes to the main(master) project.

All the changes are tracked and can be reverted if it is needed.

Merging

Git

It is an open source Distributed Version Control System(DVCS) used for source code management. That means entire copy of code and history are available on every developer’s local repository(local system). It is a command line tool. Earlier Centralized Version Control System(CVCS- Client-Server approach) was used. Later most of the developer community moved to DVCS.

Distributed Version Control System
Central Version Control System

When a developer starts to work on the same project, a new branch is created. Every branch is independent of each other. It ensures that always master branch has a production quality code.

Advantages of using git

  1. Track changes in source code
  2. Allow multiple users to work together
  3. Supports non-linear workflows because thousands of parallel branches.
  4. Ability to handle large project efficiently.

Lets get back to GitHub now. What is GitHub?

GitHub is a hosting service for Git repositories. It is built on Git. It has built-in user management feature. It allows you to work with anyone from anywhere. GitHub open source community provides access to millions of open source projects. Working with open source project is awesome to learn new skills and collaborate with bright programmers.

Get started with Git and GitHub

  1. Install Git :- You can either install it as a package or via another installer or download it from its official site. To download the Git installer, visit the Git's official site and go to download page. Click on the package given on the page as download 2.31.1 for windows. The download will start after selecting the package. Click on the downloaded installer file. Once you install it, you can use Git BASH (for windows users) to run the Git commands. We have to specify some configuration settings at the very first time.

Set your name

git config –global user.name “Your Name”

Set your email address

git config –global user.email username@example.com

Set the default editor

git config --global core.editor "code --wait"

Set the Line Ending (input for mac/Linux, true for windows)

git config –global core.autocrlf true

You can use Git documentation for finding out commands or use Git help command.

git --help

Go through Git Guide for more details.

2. Sign up for a free GitHub account :- You will get unlimited access to public repositories.

Sign up page-GitHub

3. Create a Repository(repo) :- Simply says it is a bucket to stores everything including files, images, videos, datasets, etc of a project. Add a README file is important under repo. It gives specific information about the project.

To create a new repository, hit “new repository” in the upper-right-hand corner. You can then name your repository, include a brief description, and click the check box “Add a README file” under “initialize this repository with:” Finally, you’ll click “create repository”.

4. Create a branch :- Your repo has definitely a branch called master. It allows you to edit multiple versions of a repo at once. Eventually we will commit to the master branch. When a new branch is created, it is a copy of the master branch until you make new changes. A branch goes through several steps and approvals to merge with the master branch.

Branching and Merging

Navigate to your new repository, click the dropdown that reads “branch: master,” type a branch name, and then hit “create branch”.

Forking :- Copying a repository from one user’s account to another. This enables you to take a project that you don’t have write access and modify it under your own account.

5. Committing Changes to a Branch :- If you want to make changes to your branch, navigate to the code view of your branch. Then click the file you want to change, and hit the pencil icon, make any necessary edits, write a commit message explaining why that change was made. And then click “commit changes”.

Every saved changes is called commit. These commit messages give a history of changes and let project contributors to understand how the project has changed over time.

6. Open a Pull Request :- If any branch to be merged with another person’s branch, open a pull request is a must. Once you complete a commit, you can open a pull request. It shows content differences between branches in red and green colors. i.e changes, additions, subtractions.

To open a pull request, go to the “Pull requests” tab and hit the button “New pull request”. Next, in the “example comparisons” box, find the branch you made changes and compare it with the master. Ensure you like the changes and then click the “create pull request” button. Title your pull request and briefly describe the changes. To finish, click “create pull request”

7. Merge Your Pull Request :- If you want to merge your changes to the main branch(master), click on “Merge pull request” button. Select “confirm merge”. Once you merged into master, delete the branch you used to merge .

Merging
Delete after merging

That’s all about GitHub. If I missed anything drop your suggestions in the comment section below.
Happy Coding..

--

--

Issath Sesni
Issath Sesni

No responses yet