-
Notifications
You must be signed in to change notification settings - Fork 0
Git
Version control, also known as source control, is the practice of tracking and managing changes to software code.
Git is a free and open-source distributed version control system. It is designed to handle everything from small to very large projects with speed and efficiency.
Different software can be installed on different operating systems.
- On Mac, Linux, and centOs operating systems we can use their package managers to install the software. We need to use
sudoto execute these commands- Mac :
sudo brew install git - Linux:
sudo apt-get install git - centOS:
sudo yum install git
- Mac :
- Windows: On widows download git from https://git-scm.com/downloads and click on the installer and follow instructions to finish the installation.
Note: Follow Installations to get more details about installations in general for different operating systems
To verify whether the installation run the below command and check the output:
git --version
To track who made the change git identifies the users by their identity. A user is identified by his name and email. Run the below commands to configure the identity:
-
Syntax:
git configure user.name "<Name>"git configure user.email "<Email>" -
Example:
git config user.name "Deepak Reddy Sama"git config user.email "deepak.sama26@gmail.com"
Note: To configure for all the projects, use --global in the above command. Ex. git configure --global user.name "Deepak"
- Commit :
- Head

| git command | Description |
|---|---|
| git init | Turns the current working directory to the git repository. |
| git init <repository> | Creates the repository with the given name <repository> |
| git status | Shows the status of the current working directory or workspace or working tree |
| git add <file/files> | Adds given file or files to staging area i.e it starts tracking file/files |
| git commit | Opens an editor to provide comments for change and record changes to the local repository with given comments |
| git commit -m " comments " | Moves all the staged files to the local repository with given comments |
| git rm <file/files> | Untracks the given file/files and deletes file/files from file system |
| git rm cached <file/files> | Untracks the given file/files and but do not delete file/files from file system |
| git log | Show commit logs in a repository in sequential order with details |
| git log ---online | Show commit logs in a repository in sequential order with details in a single line |
| git command | Description |
|---|---|
| git diff <file/files> | Show changes between working tree file/files and staged file/files |
| git diff HEAD <file/files> | Show changes between working tree file/files and committed file/files |
| git diff --staged HEAD <file/files> | Show changes between staged file/files and committed file/files |
| git diff <commitid> <file/files> | Show changes between working tree file/files and file/files from specified commit id |
| git command | Description |
|---|---|
| git branch | Lists all the branches. Show * in front of the current or active branch |
| git branch <branch-name> | creates a branch with the given branch name |
| git checkout <branch-name> | Switch to branch branch-name |
| git checkout -b <branch-name> | Creates and Switches to branch branch-name |
| git checkout <branch-name> | Switch to branch branch-name |
| git branch -d <branch-name> | deletes a branch with the given branch name |
| git command | Description |
|---|---|
| git clone <repository> | Clone a remote repository into a new directory |
| git clone <repository> | Clone a remote repository into a new directory |
| git pull | Incorporates changes from a remote repository into the current branch |
| git push | Updates remote repository with local repository changes |
| git push | Updates remote repository with local repository changes |
Note: To work with a remote repository you need to establish a secured shell authentication mechanism