Getting Started with Git and GitHub: A Complete Tutorial for Beginner

Search for a command to run...

This is very helpful and clearly written Thanks, Riya for this wonderful blog
👍
Are you a professional developer or a newbie? Did you go to a coding school, or are you self-taught? unfortunately, you’re not done learning yet! So In this series, you get all the dev-related stuff.
From cloud computing to DevOps to Project Management, GIT is probably the best source code management tool of this era. Git's prominence in DevOps makes it clear that there will be plenty of job prospects in the near future. So, taking this into cons...
The highly anticipated Grand Finale of the Gen AI Exchange Hackathon 2025, by Google Cloud powered by Hack2skill, concluded on 29 Nov at The Leela Palace, Bengaluru. The in-person finale served as the culmination of 5 months of innovation, bringing t...

On Cloud Nine: Look, we have ourselves a GUINNESS WORLD RECORD™ title 🏆 Guess who secured the GUINNESS WORLD RECORD™ title for most participants in an agentic AI day hackathon? Yes! We are talking about Hack2skill! On 26-27 July, we hosted Google Cl...

Build Fest ’25, hosted by FlutterFlow and Google Cloud, powered by Hack2skill, brought together a nationwide community of developers and focused on leveraging FlutterFlow and Gemini to solve real business challenges. Over a two-month journey, partici...

After weeks of ideation, building, and collaboration, Build Fest ’25 concluded with a showcase of innovative solutions built using FlutterFlow, Gemini, and Google Cloud. With 170+ submissions and 3,400+ participants, the winning applications stood ou...

The ABC Hackathon 2024, organized by ABC Conclave, with Hack2skill as the innovation partner, was a pioneering initiative aimed at advancing blockchain innovation on a global scale. Supported by Gora Network and Internet Computer as hackathon sponsor...

Hey techies đź‘‹ . Looking to get started with Git and GitHub?
In this blog, We will discuss how to use Git and GitHub as a beginner, various git commands, and their use. We will learn to create a repository, push code, create branches, issues, etc. on GitHub. So let's begin.
Git and GitHub are very important development tools that every developer must know. So, without wasting any further time, let’s start learning it.
To get the exact knowledge of Git and GitHub, you first need to know about version control.
Let’s get started!
Let's first understand what is the Version Control system
Developers can freely contribute to open-source projects and check the latest version of codes with the help of a version control system.
Basically, it’s a system that permits you to record changes to files over time, thus, you can view specific versions of those files later on.
A version control system, or VCS, keeps track of the changes made while individuals and groups work together on projects. Teams may run tests, patch issues, and add new code as the project develops knowing that any version can be retrieved at any time.
Now, after, knowing about version control, it will be much simpler for you to comprehend Git.
Just before we move ahead, let's look at how Git and GitHub work and how they are different from each other.

Similar to DropBox or Google Drive, GitHub is an online program that lets users host files, but it is made specifically to host Git Repositories. Programmers typically use Git, a command-line tool, to control the versioning (history) of software projects. Every project is housed within a Git Repository, which keeps track of all modifications.
Note - We can use Git without GitHub but vice-versa is not true. GitHub has several alternatives like GitLab, BitBucket, and more.

Git is designed for text-based data, for instance codes, books, papers, article, etc.
Git is a popular version control system. To make it more clear, let’s think of it as a caretaker that will take care of your project and this caretaker has many superpowers, let’s see some of them.
We may infer from the name that it is a Hub with initiatives, communities, etc. GitHub is a hosting service for Git repositories that offers a web-based graphical user interface. It is the world's biggest community. When a project is open-source, its specific repository is made public and receives numerous contributions.
We can access Github central repository via HTTPS or SSH.
The key benefits of GitHub are as follows:
Git installation on your PC appears to be simple. However, it also relies on your operating system. To install git on your system go to the official website and install the latest version of git on your operating system or if you are a Linux user then, you only need to open their preferred terminal and run the script as follows:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git

After downloading it,you just need to install the software and click next. Now, once you have installed the software you can check whether it is successfully installed or not by using the git version command.
After installation, Check the git version with the following command. Type this command in the Command line / terminal or gitbash.
git -- version
The output of the above should look like this

This indicates that you have successfully installed git.
Now you’re ready to start using Git on your system!
If you are using git for the first time , then you need to set up your email and username using config commands. To do so, use these commands in terminal/cmd .
git config -- global user.name “your_username”
git config -- global user.email “your_email”
Now, if we want to check whether our email and username have been set up or not, then use these commands
git config -- global user.email
git config -- global user.name

To use git, developers use specific commands to copy, create, change and combine code. Let’s learn and study these commands.
git init initializes a new git repository. It adds a hidden subfolder within the existing directory that houses the internal data structure required for the version control. To use git commands, you have to use a command inside that project folder in the command prompt.

Tipđź’ˇ- Always make sure you are inside the correct folder. You can also run git help to know more about the specific command.
✨Now to use Git, the command is:
git init

After using this command, you won’t notice any change in your git-tut folder but a hidden file has been added with the name .git.

Now, you can use any git commands in this project. Hence, in order to use git commands in your project, you first need to convert your project folder to a git repository by using the “git init” command.

So, from the above picture, we can see that there are 3 states in git
When you make a change in a file, the changes are saved in the local directory but they are not a part of the git development history. To create a commit, you first need to stage the changed files.
When the file is added to Git using git add "file_name" it's in the staged state. In this state, all the necessary changes have been made and it is ready to be committed.
You can add or remove changes in the staging area.
When we make changes in a committed file it goes into the modified state.
It stages a change. To make Git know about the files you have added to the folder, you have to add those files in Git as well.
git add . // Used to add all your files to the stage (the place where you can pick which files to commit at once)
git add <filename1> // Used to add the particular filename mentioned

Here you can see that now Git recognizes that I have added a new file.
It shows the status of changes as untracked, modified, or staged. In short, we can say that shows the list of changed files or files that have yet to be staged and committed.
The tracked files are shown with green files whereas untracked files are shown in red color.
E.g : Tracked File

Untracked File

Now, After adding all the files, we will create our first commit using the command. Commit command saves the snapshot to the project history. It functions like taking a photo.
To make it more clear, commit means to lock or finalize the changes.
Let’s create our first commit using the following command:
git commit -m "commit message"

What if I want to know what all changes have been made? So, in this situation, I’ll use the git diff command to track the difference in the changes made on a file.

Here, the + sign symbolizes the changes added.
Git branching is a very powerful feature and an important one to know. Git Branching is a series of changes.
Each developer has his/her task, and by using branches, they can work on the new feature without the interference of other teammates. Once the task is finished, you can merge new features with the main version (master branch). And this is known as the merging of a branch.

Now, to check branches in your repository,
git branch
It will list down all the branches contained in the repository.
git checkout -b "BranchName"

git branch -d "BranchName"

Hop on to GitHub and create your own GitHub account that you will use to create remote repositories and get started with your Open - Source Journey.
Tipđź’ˇ- If you're a student, do consider getting a GitHub Student Developer Pack which provides you with different tools and resources to head start your tech journey.
Click on the "+" And select "New Repository".

Enter a name for your repository and click create a repository by leaving everything on default.
✨Your repo is created. Now, you can start working on it.

Connecting your local repository to a remote repository
The GitHub repository we have created is empty, we have to upload our project into it. To do this we have to connect our remote repo(called origin) with our local repo. To do this, we need to copy the remote repo link.

To check if the remote is added successfully or not use the following command
git remote -v

Now, it's time to push our code which will send the local commits to the remote branch of the repository.
git push origin main

Now, once you go to your remote repository and refresh the page you will see that the code is uploaded on GitHub.
GitHub is your friend. You must become knowledgeable about the fundamentals of using this effective weapon since it is here to stay and won't be going away any time soon. You cannot afford to put off acquiring this skill as a new developer, and the more you know now, the more prepared you will be for your future employment.
Git And GitHub are important for every developer. The aim of this blog was to get you started with Git and GitHub and teach you some basic git commands. After successfully completing this tutorial it's time for you to take off the training wheels and explore these tools on your own. Please leave a remark or question in the space provided below.
Welcome to the open-source community through Git and GitHub, where every idea takes the form of a Pull Request.
Happy Learning!