
Git is a valuable tool for the ones who are in the software industry, and it is the most popular version control system in the world and used by 90% of the industry. It is no doubt a very important skill to have on your resume when starting your career in the industry. In the following article, we will understand what is Git and its basic workflow.
What is Git?
Git is the most popular version control system in the world and used by the majority of the IT industry. A version control system records changes made in the files over time and can store those changes in a repository.
Through a repository, Programmer can monitor their project code and modify them accordingly using a repository . We can also revert to any version of the files if we have made a mistake in the process. Without version control system the developers will store multiple versions of the files they are working on if any changes are made and the job will become exhausting if multiple developers are working on the same project. With Git we can track our work history and collaborate easily on the project.
This simple concept of recording changes throughout the development cycle has proven efficient and has opened consequential applications.
Why use Git?
Git is valuable for multiple reasons. It is a distributed version control system which means every developer working on the project has access to the codebase of the files including its complete history. Git is free and open-source which means it can be used by anyone without any charges. It is also easy to understand and extremely scalable.
What is Git Workflow?
Git workflow also referred to sometimes as Gitflow is a branched based development procedure that helps the team of developers for continuous deployment of the project. Git workflow is an ideal choice for projects with schedule release cycle and for DevOps project. But since Git workflow is simple and efficient it is suitable for any projects with different scales and practices.
Understanding Git Workflow
For beginners to understand the process of basic Git Workflow we will need to know three things.
1) Project directory
2) Staging area
3) Repository
Project Directory
Project Directory is the directory that contains all the files and codes of the project. The programmer can modify the project using project directory.
Staging Area
The staging area is also known as the index is the snapshot of the project directory. When we use git add .
command the exact copy of the project directory is made in form of a snapshot. It is an intermediate step between the project directory and repository. Some people find this step as an unnecessary step but for beginners, it is a lifesaver because when you are confirming that your snapshot of the project is correct then you can commit it to the repository which reduces the chances of mistake.
Repository
Git repository is a sub directory within the project directory in a form of .git/
. This directory records all the changes in the project directory over time.
Code for the process-
\\Code for initializing repository
git init
\\Code for adding content in staging area
git add .
\\Code for committing in repository
git commit -m "Initial Commit"
\\Code for pushing local content in master branch
git push -u origin master
\\Code for pull request from master branch
git pull upstream master