Skip to the content.

What is Git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

Types of Version Control Sysems

Version control systems are tools that help a software team manage changes to source code over time.

For almost all software projects, the source code is like the crown jewels - a precious asset whose value must be protected.

VCS are sometimes known as SCM (Source Code Management) tool.

Most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source tool originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel.

Two types Version Control systems
1) Centrailized Version controlling
2) Distributed Version controlling

Git is Distributed Version controlling.

Centralized Version Control System

Centralized Version Control is a version control system using server/client model and server contains all the history of source code.

Distributed Version Control System

One of the nicest features of any Distributed SCM, Git included, is that it’s distributed. This means that instead of doing a “checkout” of the current tip of the source code, you do a “clone” of the entire repository.

What is gitbash ?

Git Bash is an application for Microsoft Windows environments which provides an emulation layer for a Git command line experience. … A shell is a terminal application used to interface with an operating system through written commands. Bash is a popular default shell on Linux and macOS.

How to configure username and email for git?

$ git init
$ git config - -global user.name “user name”
$ git config - -global user.email “user_mail@gmail.com”

Branching and Merging

This feature is provided in git, so that developers can create code related to different functionalities on seprate branches.
This helps the development team in creating the code in an uncluttered way.
Later this code can be merged with master branch.
Default branch of git is “Master”

The Git feature that really makes it stand apart from nearly every other SCM out there is its branching model.

Git allows and encourages you to have multiple local branches that can be entirely independent of each other. The creation, merging, and deletion of those lines of development takes seconds.

This means that you can do things like:

Frictionless Context Switching. Create a branch to try out an idea, commit a few times, switch back to where you branched from, apply a patch, switch back to where you are experimenting, and merge it in.

Role-Based Codelines. Have a branch that always contains only what goes to production, another that you merge work into for testing, and several smaller ones for day to day work.

Feature Based Workflow. Create new branches for each new feature you’re working on so you can seamlessly switch back and forth between them, then delete each branch when that feature gets merged into your main line.

Disposable Experimentation. Create a branch to experiment in, realize it’s not going to work, and just delete it - abandoning the work—with nobody else ever seeing it (even if you’ve pushed other branches in the meantime).

Some useful Git commands

git init —-> to make working directory as git repository
git add filename —-> to move file to staging area
git add . —-> to move all files to staging area
git rm –cached filename or git reset filename —-> bring file back to untracked section
git commit -m “first commit” —-> to move the files from staging are to local repositary
git log —-> to see the list of commit
git rebase —-> the commits from the sub branch are added to the top of the master branch
git stash —-> this feature is used for leaving unfinished work, in such a way that Git cannot access it and continue work on some other files
git stash -u —-> to stash staged and untracked files
git stash list —-> to see the list of stashes
git stash pop —-> to get back the stashed files
git stash pop stash@{stash_number} —-> to bring the older stash out