Posted by Adarsh Singh | Last Updated: 15-Jan-19
Git is a version control system for tracking changes in projects files and coordinating work on those files among multiple people and it also free and open source distributed VCS.
Version control tools keep track of every modification to the code in a special kind of database. If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members.
We have many version control system like SVN, Mercurial, Perforce, etc.
Flow chart of GIT
Basic Git commands to use it-
1. git config --global user.name/email "Username/User email - configure the author name/email.
2. git init- For creating a local repository.
3. git clone /path/to/repository- For creating a working copy of a local repository
4. git commit -am "Commit message"- To commit all stage changes with the commit message.
5. git push origin branch-name- For Send changes to the branch of your remote repository
6. git status- we can check our local changes with remote.
7. git checkout -b <branchname> - creating a new branch and switch to it.
8. git branch - Check all the branches in your local, and also tell you which branch you are currently using.
9. git merge <branchname> - To merge a different branch into the current working branch.
10. git fetch - To fetch all latest branches.
11. git pull - Update current HEAD of current branch with the latest changes from the remote server.
Advantages of using git-
1. It’s Multi-platform
It was built for the Linux kernel but supports other platforms. We can use git-scm.com for download and install instructions. Some code editors have Git integration, for saving your time on the git command line.
2. It’s Free
Git is open source under the General Public License version 2. Not all the tools and integrations are free.
3. It’s Fast
Both in terms of the number of participant and branches, as well as overall repository size, Git was built from the ground up to scale. We can consider an example of a git-based project is the Linux kernel, which has thousands of contributors, thousands of commits.
4. It’s Distributed (for Offline Work)
Git allows users to work offline and continue committing to the repository in parallel to other developers, without getting blocked on acceptance of your commits.