Introduction to Git
Git is by far the most popular contemporary version control system in use today. Linus Torvalds, the famed architect of the Linux operating system kernel, founded Git in 2005 as a mature, actively maintained open source project. Git is used for version control in an astonishing number of software projects, both commercial and open source. Git developers are highly represented in the pool of accessible software development expertise, and it works well on a variety of operating systems and IDEs (Integrated Development Environments).
Table of contents
What is Git?
- Git is a free and open-source distributed version management system designed to handle projects of all sizes with speed and efficiency.
- Git is based on the concept of distributed software development, in which several developers may read the source code of a single program and make changes to it that other developers can view.
- Linus Torvalds created and developed it for Linux kernel development in 2005.
- Every git working directory is a full-fledged repository with full history and version tracking capabilities, regardless of network connectivity or a centralized server.
How does Git work?
- A Git repository is a key-value object store where all objects are indexed by their SHA-1 hash value.
- This repository contains different types of objects like commits, files, tags, and filesystem tree nodes.
- A Git repository is a large-scale hash table that does not allow for hash collisions.
- Git operates specifically by taking “snapshots” of files.
Features of Git
- Tracks history
- Free and open source
- Generates backups
- Supports non-linear development
- Scalable
- Supports collaboration
- Branching is easier
- Distributed development
Git Workflow
There are three states in the Git workflow:
- Working directory - files changes in your working directory.
- Staging area (Index) - Prepare the files for staging and save snapshots in your staging area.
- Git directory (Repository) - Commit the snapshots to your Git directory for safekeeping. Make modifications to any existing version, stage them, and commit.
Branch in Git
In Git, a branch is used to store your changes until they are ready. While the main branch (master) remains stable, you can work on a branch. Once you’ve done it, you can merge it with the main office.
The figure above illustrates a master branch. There are two separate branches called “Feature 1” and “Feature 2”. When you’re finished with the two branches, you can merge the branches and create a master branch.
Git Commands
- git init
- git clone
- git config –global user.name
- git config –global user.email
- git add [file or .]
- git commit -m “commit message”
- git status
- git pull
- git push
- git checkout
Read Git Basic article for further information.