Basic Operations in Git
Tags: github, newbie, tutorial, git
Published: 2021-03-09 15:57:24

---
title: Basic Operations in Git
published: true
description: Basic operations in git by sameer katija
tags: Github, Newbie, Tutorial, Git
//cover_image: https://miro.medium.com/max/875/0*wluWwjYt4gaeTCU-
canonical_url: https://sameerkatija.medium.com/basic-operations-in-git-72714ded4180
---

In my previous articles, I have covered [An intro to Git and Github](https://dev.to/sameerkatija/an-introduction-to-git-and-github-for-newbies-15n2) and [How to Push a Project to GitHub](https://dev.to/sameerkatija/how-to-push-a-project-to-github-using-terminal-2h0b). Today we will learn about the basic operations of git. There are almost five basic operations in Git.

1. Initializing 
2. Add
3. Commit 
4. Pull
5. Push

If you have followed my previous articles, you might have an idea about these operations. Let's discuss them but before that, if you don't know about Git then do read my article on ["An intro to Git and Github"](https://dev.to/sameerkatija/an-introduction-to-git-and-github-for-newbies-15n2) first and then continue with this article. If you have the know-how of git. Let's continue.

## Initializing

Initializing in Git is used to convert a simple folder to a Git repository. To initialize the folder as a Git repo you need to navigate the folder which you want to be initialized as git and start the Git terminal and run the command given below.

```
git init
```

Now, your folder is initialized as a Git repo and it will have a folder named ".git", it may not be visible but you can see if you change the setting to "show hidden folders". The initialized repo is also known as the "Working directory". 

_The root folder of your project is often called the "Working copy" or "Working director". It is the directory on your local computer that contains your project's files._

## Add

The Add operation is used to adds a change in the working directory to the staging area. _A staging area is a virtual place that collects all the files you want to include in the next commit._

It Git add operation tells the git that you want the updates of a particular file, included in the next commit. However, add operation doesn't really affect the repository in any way and changes are not actually recorded until you commit the code. Add operation is performed using 

```
git add <filename> (for specific file)
git add -a (for all files)
```

## Commit

Commit operation in git is used to save all changes present in the staging area along with a short description from the user in a local repository. Commits are very much important in Git. You can think of every commit as a snapshot of your project, where a new version of that project is created in the current repository. Git commit is performed using 

```
git commit -m "user message"
```

## Pull

The pull operation is used to fetch and download data from a remote repository and merge it into the local repository to match that code or data. Git pull is performed using

```
git pull
```

## Push

Push operation is used to upload local repository data to a remote repository. Git push is performed using 

```
git push origin main
```

Now, you know about the basic operation of git. In the next article, we will focus on advance Git operations. Don't forget to share, if you find out helpful.