Lecture # 2 - Introduction to Git and Git Installation
Git. Basic Git Concepts. Git Installation on Ubuntu.
Git:
Git is an open source distributed version control system that is used for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files.
Basic Git Concepts:
Repository | Commit | Branch |
Merge | Push | Pull |
Staging Area | HEAD Pointer | Merge Conflict |
Origin | Tags | Merge Commit |
Stash | Fetch | |
Revert | Rebase |
The Four States:
Git has four states that our files can reside in:
Modified:
A file is in the modified state when we have made changes to it but have not yet added those changes to the staging area. We can use the
git add
command to move a modified file to the staging area.Staged:
A file is in the staged state when we have added it to the staging area but
have not yet committed it to the repository. We can use the
git commit
command to move a staged file to the committed state.Committed:
A file is in the committed state when we have added it to the repository.
Committed files are stored in the repository's version history and cannot be
modified directly.
Untracked:
A file is in the untracked state when it is not being tracked by Git. These are typically new files that have not yet been added to the repository. You can use the
git add
command to start tracking an untracked file.
Main Sections of Git Project:
Main sections of Git project are:
Working Directory:
This is where you modify files in your project. When you create or edit files in your project, they exist in the working directory. These changes are not yet tracked by Git.
Staging Area (Index):
The staging area is a buffer between the working directory and the Git repository. It acts as a holding area for changes that you want to commit to the repository. Before committing changes, you need to add them to the staging area. This allows you to selectively choose which changes you want to include in the next commit.
Local Repository:
The local repository is where Git permanently stores the committed changes. Once you've added changes to the staging area and then commit them, they become part of the local repository. This repository holds all the commits and their respective snapshots of the project's files.
Remote Repository:
In distributed version control systems like Git, developers often collaborate on projects hosted on remote servers, such as GitHub, GitLab, or Bitbucket. The remote repository is a copy of the project's repository hosted on a server. It serves as a centralized location for multiple developers to push their changes and pull changes from others. The remote repository allows for seamless collaboration and backup of the project.
Git Installation:
Linux:
To install git for Linux use sudo apt install git
command. We'll be using git on Linux.
Windows:
To download git for windows Click Here.
Mac OS:
To download git for Mac OS Click Here.