DEV Community

Cover image for The Git tutorial

Posted on

The Git tutorial

Git tutorial

What is Git?

Git is a free and open source software for version control, that is designed to handle all kinds of projects.

Advantages of Git

For example, let's consider people A and B working on the same project. Let's assume they are editing the same file.

If A adds some text, and B replaces some text, a problem arises. The same file is being edited by 2 people, and there arrives a clash. The text replaced by B could be one of the dependencies of A's text.

Git was introduced into this world, to solve this problem. One can edit the file, the other can also do the same, but these kinds of errors won't occur.

Installing Git

You can install git via checking out this URL:, and then selecting your operating system. Alternatively,

  • If your're using Chocolatey in Windows, open Powershell as admin and run this: choco install git -y
  • If you're using Linux, run this (according to your distro):
  sudo apt install git -y (Debian based)
  sudo pacman -Sy git (Arch based)
  sudo yum install git -y (RedHat/Fedora based)
Enter fullscreen mode Exit fullscreen mode
  • If you're using macOS with HomeBrew installed, use this command: brew install git

And now, you're ready to use Git.

Using Git

Using Git via the GUI offered by GitHub seems easier, but learning the command line is even more easier and it helps you a lot.

Here's how you can use Git with the command line:

  1. git clone url_of_repo (To clone the repository into your system)
  2. git checkout branch_name
    (to change to a separate branch)
    git checkout -b branch_name (to create a new branch and switch to it)

  3. You can create a file after changing the branch, or make any changes to already existing files.

  4. After editing/modifying the files, you have to push the changes to GitHub.

Note: For the following commands to work, you must be inside that prticular folder. Else, it won't work :)

  1. Use "git add ." ( Here, period is used to push all the files) or git add -A (same purpose)

  2. git commit -m your_message (to )

  3. git push (to push your changes to the repository)

    This might not work during a few situations, so you can use the command which is recommended by Git to use in the terminal.

And, those are the basic methods to use Git. If you master these 5 commands, you won't be needing the GUI to manage files via GitHub.

Good Luck!


Authors: Yash Wankhade and Abhay Anand

Editors: Tushar Verma, Pranav and Rasheedah

Publisher: Pranav P

Top comments (1)

bobbyiliev profile image
Bobby Iliev

For anoyone who is just getting started, I could suggest this free eBook:

GitHub logo bobbyiliev / introduction-to-git-and-github-ebook

Free Introduction to Git and GitHub eBook

💡 Introduction to Git and GitHub

This is an open-source introduction to Git and GitHub guide that will help you learn the basics of version control and start using Git for your SysOps, DevOps, and Dev projects. No matter if you are a DevOps/SysOps engineer, developer, or just a Linux enthusiast, you can use Git to track your code changes and collaborate with other members of your team or open source maintainers.

The guide is suitable for anyone working as a developer, system administrator, or a DevOps engineer and wants to learn the basics of Git, GitHub and version control in general.

🚀 Download

To download a copy of the ebook use one of the following links:

📘 Chapters

  • About the book
  • Introduction to Git
  • Version Control
  • Installing Git
  • Basic Shell Commands
  • Git Configuration
  • Introduction to GitHub
  • Initializing a Git project
  • Git Status
  • Git Add
  • Git