Learn the Basics of Git in under 5 minutes

Learn the Basics of Git in under 5 minutes

What is Git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency created by Linus Torvald, the creator of Linux in 2005. Since 2005, Junio Hamano has been the core maintainer. It is the most popular source control management tool.

We are going to learn the most basic and simple commands while kick-starting your journey with Git. As with most other distributed version control systems, and unlike most client-server systems, every Git directory on every computer is a full-fledged repository with complete history and full version-tracking abilities, independent of network access or a central server.

Features

  • Provides strong support for non-linear development.

  • Distributed repository model.

  • Capable of efficiently handling small to large-sized projects.

  • Cryptographic authentication of history.

  • Pluggable merge strategies.

  • Toolkit-based design.

  • Periodic explicit object packing.

  • Garbage accumulates until collected.

  • Super-fast and efficient performance.

  • Cross-platform

  • Code changes can be very easily and clearly tracked.

  • Easily maintainable and robust.

  • Offers an amazing command line utility known as git bash.

  • Also offers GIT GUI where you can very quickly re-scan, state change, sign off, commit & push the code quickly with just a few clicks.


Let's get right into the basic commands of Git

  • Name (username)
git config --global user.name "username"
  • Email
git config --global user.email "email address"

Note - Your username and email should be the same as those on your GitHub

  • Making a New Repository
git init <repository name>
  • Cloning a Repository
git clone <repository url>
  • Adding your files (staging the changes)
git add < file.ext >

This command adds changes to the specified file to the staging area in the repository.

git add .

This command adds changes to all files in the repository to the staging area.

  • List the changed files
git status
  • Push
git push origin master