Git — Basics

Tharun Kumar Sekar
Analytics Vidhya
Published in
3 min readMay 29, 2020

Git is a powerful tool, but it has a reputation of baffling newcomers. With the right knowledge, anyone can master git. Once you start to understand it, the terminology will make more sense and you’ll (eventually) learn to love it.

What is Git?

Git is a type of version control system (VCS) that makes it easier to track changes to files. For example, when you edit a file, git can help you determine exactly what changed, who changed it, and why.

It’s useful for coordinating work among multiple people on a project, and for tracking progress over time by saving “checkpoints”. You could use it while writing an essay, or to track changes to artwork and design files.

Git isn’t the only version control system out there, but it’s by far the most popular. Many software developers use git daily, and understanding how to use it can give a major boost to your resume.

Environments in GIT

Working Directory: The directory where you have cloned the files in your system.

Staging Area: Temporary location to stage your files before you perform a commit. This area helps you to commit only required files and skip the remaining files.

Local Repository: Replica of the remote repository which will carry your commits.

Remote Repository: A common repository that everyone can use to exchange their changes. It is most commonly located on a remote server.

Pull: Once you have your branch created in the remote repository, you have to perform a git pull , which will sync your local repository with the remote server. Right after your perform a pull, the newly created branch will be available in your local repository.

Checkout: After you perform a pull you will have your new branch in your local repository. Now you need to perform git checkout branchname to point your working directory to the new branch.

Add: When you complete your changes in your local machine, you can do a git add to add the changes to the staging area. Some of the different functionalities of the add command are

  • git add * to add all your changed files to staging area
  • git add filename to specifically add a file to staging area
  • git add -p to look at individual changes in each file and then add it to staging area

Commit: Once you have staged the required files, you can do git commit -m "message" to commit your changes to your branch. A commit is the one which will be pushed to the Remote repository once your perform a git push.

Push: Until you do a push, all your changes will still be in your local machine and you can’t exchange it with anyone. git push pushes all your local commits to the remote repository. Now anyone can access your changes by going to your branch.

If you liked this article, click the 👏 so other people will see it here on Medium.

--

--