Git and GitHub: Introduction

Ronak PaulRonak Paul
5 min read

In the world of software development, collaboration is key. Teams of developers work together to create amazing applications, websites, and programs. But how do they keep track of all the changes, updates, and improvements they make to their projects? That's where Git comes into play. In this blog post, we'll dive into the world of Git & GitHub, explaining what it is and how it can make version control a breeze.

What is Git?

Git is a distributed version control system (DVCS) that was created by Linus Torvalds in 2005. It's designed to help developers manage and track changes to their codebase efficiently. With Git, multiple developers can collaborate on a project without the risk of overwriting each other's work or losing track of changes. For example, you wrote a code and after that, you made some changes to the code and you saved your work but the next day you saw that the changes that you made broke the whole application and you need a way to go back to your previous code for those cases Git is very useful because it keeps track of your work and you can go back to your previous work if necessary and you can also see where and in which line you made those changes.

What is GitHub?

GitHub is a web-based platform and service that provides a wide range of tools and features for software developers and teams to collaborate, manage, and host their code repositories. It is one of the most popular and widely used platforms for version control and collaborative software development.

If you are working on a project and that project is on your local machine but if you want to share all the code history and project files on the internet so that everyone can see your code and also they can collaborate and make changes to your code that would be great right? So to do this GitHub comes into the picture where you can put your project files and the history of the project in GitHub. In summary, GitHub is a platform that combines the power of Git for version control with a suite of collaborative and project management features. It is widely used by individual developers, teams, and open-source communities to host, collaborate on, and manage software projects.

Key Concepts of Git

  • Repository: A Git repository, or repo for short, is a directory that contains all the files and folders for a particular project, along with the entire history of changes made to those files.

  • Commit: A commit is like a snapshot of your project at a specific point in time. It records the changes you've made to the files in your repo. Each commit has a unique identifier (a long string of letters and numbers) and a commit message that describes the changes made.

  • Branch: A branch is a separate line of development within a Git repo. Developers can create branches to work on new features or fix bugs without affecting the main codebase. Once the changes are complete and tested, they can be merged back into the main branch.

  • Merge: Merging is the process of combining the changes from one branch into another. This is often used to integrate completed features or bug fixes back into the main branch (usually called "master" or "main").

Benefits of Using Git

  1. Version Control: Git allows you to track changes to your code over time, making it easy to roll back to previous versions if needed.

  2. Collaboration: Multiple developers can work on the same project simultaneously, resolving conflicts efficiently.

  3. Branching: Creating branches for new features or bug fixes keeps the main codebase stable.

  4. Remote Hosting: Platforms like GitHub provide remote hosting for your Git repositories, making it easy to share your code and collaborate with others.

  5. Open Source: Git is open source and widely adopted, with a vast community and plenty of resources for learning and troubleshooting.

Installation of Git & GitHub

For the installation of Git, go to the official website of Git which is given below and install the Git on your local machine.

Install Git Here

After installing Git, you should create your GitHub profile. Go to the GitHub website from below:

GitHub

After installation of Git and creating your GitHub account you should follow the below steps to setup your Git on your local machine :

  1. The first thing you should do is to set your username and email which you have given in your GitHub account by using the below commands:

     git config --global user.name "YOUR_USER_NAME"
    
     git config --global user.email YOUR_EMAIL_ADDRESS
    
  2. By default, Git uses the default branch named master when you initialize a git repository by using git init command but in the latest version of GitHub the default branch is the main branch. So we have to set the default branch to the main branch in Git. To do so use the below command:

     git config --global init.defaultBranch main
    
  3. Now if you want to check your git configuration settings, you can do so by the below command:

     git config --list
    

That's it for this blog. In the next blog I will list and explain all the important git commands and their uses. Follow for more blogs like this and subscribe to my newsletter. Happy coding. ✌

1
Subscribe to my newsletter

Read articles from Ronak Paul directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ronak Paul
Ronak Paul

I am a full stack developer and student from India. Building and contributing to community.