DEV Community

Cover image for What are Git and Github? Why are they used?
Sai Karthik
Sai Karthik

Posted on

What are Git and Github? Why are they used?

Have you ever wondered what Git & Github are, and why they are being used? Read on to know more about them!

Version Control System:

What is a Version Control System?

A system that helps us to maintain the different versions of our work and retrieve back whichever version is needed later.
Version Control Systems enable you to make periodic, manual “commits” to your project’s “repository” to save code as you go. Every time you commit, it goes down as a version of your project within the version control system. If you ever want to go back to an exact version of your project at a specific time, you’ll be able to do so just by using the commit you wish to revert to.
This makes it very helpful to fix mistakes without spending much time. A version control system is a powerful tool for both teams and individual programmers.

Git

What is Git?

Git is a type of version control system. It is widely adopted now by several projects.
It is a software tool that enables the management of changes to source code.

GitHub

What is GitHub?

GitHub is an online code hosting platform that integrates with Git to host your code online and helps in version control and collaboration.
It lets you and others work together on projects from anywhere.
Github lets you manage Git repositories.
Many large companies have their open-source projects hosted on GitHub.

Repository:

A repository contains all of your project's files and each file's revision history. You can own repositories individually, or you can share ownership of repositories with other people in an organization.
Your repository is everything inside of the .git folder in your project. It holds all the metadata for your project, such as references to configuration, description of your repository, as well as all of the major logs made to the project as a whole.

Branch:

Branching means you diverge from the main line of development and continue to do work without messing with that main line.
A branch is used to isolate development work without affecting other branches in the repository. Each repository has one default branch, and can have multiple other branches. You can merge a branch into another branch using a pull request.
Creating a separate branch that is either a working copy of the production branch or is completely different from it gives you the ability to leverage Git and work simultaneously with new features while one version of your software is in production.

Commit:

Commit is like a snapshot of your repository. These commits are snapshots of your entire repository at specific times. You should make new commits often, based around logical units of change. Over time, commits should tell a story of the history of your repository and how it came to be the way that it currently is. Commits include lots of metadata in addition to the contents and message, like the author, timestamp, and more.

Pull Requests:

Pull Requests are the heart of collaboration on GitHub. When you open a pull request, you’re proposing your changes and requesting that someone review and pull in your contribution and merge them into their branch. Pull requests show diffs, or differences, of the content from both branches. The changes, additions, and subtractions are shown in green and red.

Cheatsheets:

Github has provided these cheatsheets which contain commands and a quick glossary. They come in handy while working with Git and Github.
Git Cheatsheet - 1
Git Cheatsheet - 2

Top comments (0)