Version Control, also known as Source Control, is the process of tracking and managing changes to files over time. Version Control Systems (VCS) are software tools designed to help teams work in parallel.
✓ How Does Version Control Work ?
Version control systems allow multiple developers, designers, and team members to work together on the same project. It helps them work smarter and faster! A version control system is critical to ensure everyone has access to the latest code and modifications are tracked. As development becomes increasing complex and teams grow, there's a bigger need to manage multiple versions and components of entire products.
✓ 5 Things to Look for Version Control Software
- Automation.
- Team Collaboration.
- Concurrent Development.
- Tracked Changes (Who, What, When, Why)
- High Availability (or) Disaster Recovery.
✓ GIT Introduction
GIT is a modern and widely used Distributed Version Control System in the Projects. GIT is designed and developed by Linus Torvalds for Linux Kernel Development in 2005. GIT is mainly using Manage Projects with high speed and efficiency. The Version Control System allows us to monitor and work together with Project Team Members.
✓ Life Cycle of GIT
- Developer clone the Project from GIT Repository as a working copy.
- Developer change the Branch Name of the Project.
- Developer modify the working copy by adding (or) editing files.
- If necessary, also update the working copy by taking other developer's changes.
- Developer review the changes before commit.
- Developer commit changes. If everything is fine, then you push the changes to the repository.
- After committing, if you realize something is wrong, then you correct the last commit and push the changes to the repository.
✓Different Between GIT and SVN
- GIT is a distributed version control system.
- Git is an Source Code Management (SCM).
- Git has a cloned Repository.
- Git does not have a Global Revision Number.
- Git stored content as metadata.
- Git has more content protection than SVN.
- Linus Torvalds developed git for Linux kernel.
- Git is distributed under GNU (General public license).
- SVN is a Centralized Version Control System.
- SVN is Revision Control.
- SVN does not have a cloned Repository.
- SVN has a Global revision number.
- SVN stores content as files.
- SVN's content is less secure than Git.
- CollabNet,Inc developed SVN.
- SVN is distributed under the open-source license.
✓ git config
Definition | git config command sets the author name and email address respectively to be used with your commits. |
Syntax for Author Name | git config –global user.name "[name]" |
Syntax for Email Address | git config –global user.email "[email address]" |
Example for Author Name | git config –global user.name "JaladhiSoftTechnology" |
Example for Email Address | git config –global user.email "jaladhisofttechnologies@gmail.com" |
✓ git init
Definition | git init command is used to start a new repository. |
Syntax | git init [repository name] |
Example | git init /home/jaladhisofttechnology/document/jst |
✓ git clone
Definition | git clone command is used to obtain a repository from an existing URL. |
Syntax | git clone [url] |
Example | git clone https://github.com/jaladhisofttech/employee.git |
✓ git branch
Definition | git branch command lists all the local branches in the current repository. |
Syntax | git branch |
Example | git branch |
✓ git branch [branch name]
Definition | git branch [branch name] command creates a new branch. |
Syntax | git branch [branch name] |
Example | git branch JST |
✓ git add
Definition | git add is used to adds a file to the staging area. |
Syntax | git add [file] |
Example | git add employee |
✓ git commit
Definition | git commit records or snapshots the file permanently in the version history. |
Syntax | git commit -m "[Type in the commit message]" |
Example | git commit -m "Updated the Employee Service Class" |
✓ git commit -a
Definition | git commit -a is used commits any files you have added with the git add command and also commits any files you have changed since then. |
Syntax | git commit -a |
Example | git commit -a |
✓ git diff
Definition | git diff command shows the file differences which are not yet staged. |
Syntax | git diff |
Example | git diff |
✓ git diff –staged
Definition | git diff –staged command shows the differences between the files in the staging area and the latest version present. |
Syntax | git diff –staged |
Example | git diff –-staged |
✓ git diff [firstBranch] [secondBranch]
Definition | git diff [firstBranch] [secondBranch] command shows the differences between the two branches mentioned. |
Syntax | git diff [firstBranch] [secondBranch] |
Example | git diff jst jst1 |
✓ git tag
Definition | git tag [commitID] command is used to give tags to the specified commit. |
Syntax | git tag [commitID] |
Example | git tag b01775f589389ujghf890382m89nkl0091234 |
✓ git show
Definition | git show [commit] command shows the metadata and content changes of the specified commit. |
Syntax | git show [commit] |
Example | git show n091775f589389ujghf890382m89nkl0094 |
✓ git log
Definition | git log command is used to list the version history for the current branch. |
Syntax | git log |
Example | git log |
✓ git log –follow [file]
Definition | git log –follow [file] command lists version history for a file, including the renaming of files also. |
Syntax | git log –follow [file] |
Example | git log -–follow jst |
✓ git rm
Definition | git rm command deletes the file from your working directory and stages the deletion. |
Syntax | git rm [file] |
Example | git rm jst |
✓ git status
Definition | git status command lists all the files that have to be committed. |
Syntax | git status |
Example | git status |
✓ git reset
Definition | git reset command unstages the file, but it preserves the file contents. |
Syntax | git reset [file] |
Example | git reset jst.css |
✓ git reset [commit]
Definition | git reset [commit] command undoes all the commits after the specified commit and preserves the changes locally. |
Syntax | git reset [commit] |
Example | git reset u89ijk09836472nhbgf7483920 |
✓ git reset -hard [commit]
Definition | git reset [commit] command discards all history and goes back to the specified commit. |
Syntax | git reset --hard [commit] |
Example | git reset u89ijk09836472nhbgf7483d3210 |
✓ git reset -soft [commit]
Definition | git reset [commit] command discards some history and goes back to the specified commit. |
Syntax | git reset --soft [commit] |
Example | git reset u89ijk09836472nhbgf673h889m83920 |
✓ git branch -d [branch name]
Definition | git branch -d [branch name] command deletes the feature branch. |
Syntax | git branch -d [branch name] |
Example | git branch -d jst |
✓ git checkout [branch name]
Definition | git checkout [branch name] command is used to switch from one branch to another branch. |
Syntax | git checkout [branch name] |
Example | git checkout jst |
✓ git checkout -b [branch name]
Definition | git checkout -b [branch name] command creates a new branch and also switches to it. |
Syntax | git checkout -b [branch name] |
Example | git checkout -b jst |
✓ git merge
Definition | git merge command merges the specified branch’s history into the current branch. |
Syntax | git merge [branch name] |
Example | git merge jst |
✓ git remote
Definition | git remote command is used to connect your local repository to the remote server. |
Syntax | git remote add [variable name] [Remote Server Link] |
Example | git remote add origin https://github.com/jaladhisofttech/jst.git |
✓ git push
Definition | git push command sends the committed changes of master branch to your remote repository. |
Syntax | git push [variable name] master |
Example | git push origin master |
✓ git push [variable name] [branch]
Definition | git push [variable name] [branch] command sends the branch commits to your remote repository. |
Syntax | git push [variable name] [branch] |
Example | git push origin master |
✓ git push -all [variable name]
Definition | git push -all [variable name] command pushes all branches to your remote repository. |
Syntax | git push –all [variable name] |
Example | git push --all origin |
✓ git push [variable name] : [branch name]
Definition | git push [variable name] : [branch name] command deletes a branch on your remote repository. |
Syntax | git push [variable name] : [branch name] |
Example | git push origin : jst |
✓ git pull [Repository Link]
Definition | git pull [Repository Link] command fetches and merges changes on the remote server to your working directory. |
Syntax | git pull [Repository Link] |
Example | git pull https://github.com/jaladhisofttech/jst.git |
✓ git stash save
Definition | git stash save command temporarily stores all the modified tracked files. |
Syntax | git stash save |
Example | git stash save |
✓ git stash pop
Definition | git stash pop command restores the most recently stashed files. |
Syntax | git stash pop |
Example | git stash pop |
✓ git stash list
Definition | git stash list command lists all stashed changesets. |
Syntax | git stash list |
Example | git stash list |
✓ git stash drop
Definition | git stash drop command discards the most recently stashed changeset. |
Syntax | git stash drop |
Example | git stash drop stash@{0} |