This happens with Git commands

Introduction

Git is a version control system, which makes it possible to handle file changes. Git helps determine what has changed, who changed and why.

Basic Git commands

A prerequisite for working efficiently with version control is to have knowledge of the most basic Git commands and flows they give rise to.

The local computer has three different areas, working directory, staging area and local repository.

In the working directory you make all changes, such as adding new files (marked as untracked), modifying files (marked as modified) and deleting files (marked as deleted). By using git status you can get the current status of your working directory, and see if there are any changes that need to be added to staging area.

In order for changes made in working directory to be sent to local repository, they must first be placed in staging area, which you do with git add ., in preparation for a commit.

Local repository contains all commits (and branches).

On a server is what is called a remote repository.

Simple Git Flow

git clone <repository>

Downloads a repository to your computer. By default, a directory is created, "working directory" , with the name of the repository, containing all files. The argument <repository> is a Git URL to a "remote repository" and is called "remote origin" , the location from which the files were originally retrieved.

git add

After making changes in "working directory" , this command marks changes made as staged, meaning that they are ready for a "commit" . With the command given status you can check if there are changes that are " staged " or not.

git commit -m '<write an imperative message>'

Saves changes found in "staging area" locally in "local repository" .

git push

Uploads content, "commits" , in "local repository" to "remote repository" .

git pull

Merges changes from "remote repository" with current "branch" (main).