Last updated 27/07/2021
Git is one of the most popular DevOps tools, widely used across the software industry. It’s a distributed SCM (source code management) tool, loved by remote teams and open source contributors. Git allows you to track the progress of your development work. You can save different versions of your source code and return to a previous version when necessary. It’s also great for experimenting, as you can create separate branches and merge new features only when they’re ready to go.
Let me put it this way- Git is a place where you can:
If you are a coder/ programmer/ developer, you have to know Git.
Git allows developers to download a new version of the software/project/code/file, make changes, and upload the newest revision.
Git key terminologies include:
The DevOps approach needs a version control system that will track all the changes. Git is a distributed version control system that allows developers to keep a local copy of the commits they make. GIT as a DevOps tool empowers collaboration and faster release cycles, and that is what the DevOps concept is based upon.
Version control is one of the best practices of DevOps. With version control, developers working on a project can version the software, share, collaborate, merge, and have backups.
When working in large organizations, where multiple teams work together on the same project, Git comes in handy and makes it easy to track changes made by each team. It helps in tracking code, version control, and effective management of code.
Anyone willing to start or approach DevOps as a career should start from the basics, and GIT is the fundamental tool that overrides everything else.
Every company is now powered by software in one or the other ways. There are multiple projects handled by many developers in an organization, and they all need the means to track, upload, and receive changes to the code base. Effective repository management services are the key to fast and efficient software development. The most popular ones based on Git are GitHub, Bitbucket, and GitLab.
GitHub is a git-based repository host launched initially in 2008 by PJ Hyatt, Tom Preston-Werner, and Chris Wanstrath. As of now, GitHub is the largest repository hosting platform with more than 38 million projects. It authorizes to host and review code, manage projects, and build software.
Bitbucket was also launched in 2008 by an Australian startup and it initially supported only for Mercurial projects. In 2010 Bitbucket was smartly bought by Atlassian, and from the next year, it started supporting Git hosting, which is now its primary focus. Bitbucket has become a household name and provides free unlimited private repos, many powerful integrations like Jira and Trello, and has built-in continuous delivery.
GitLab started as a small project in 2011, aiming to provide an alternative to the available repository management solutions. The company was only incorporated in 2014. Gitlab now provides a complete DevOps setup for the organizations from continuous integration and delivery, agile development, security, etc.
One of the most common questions everybody asks is the difference between Git and Github. Git is the tool/technology that allows versioning of code and Github is the centrally hosted Git server where the Git repository lives. Developers use the remote repository hosted on Github to share their work among themselves. Github is just one of the many tools such as Gitlab, BitBucket, etc.
To get started with Git you must have it on your computer. If you don’t already have it you can go to the git website and follow the instructions.
Initialize a new Git repository: Git init
Everything you code is tracked in the repository. To initialize a git repository, use this command while inside the project folder. This will create a .git folder.
This command adds one or all changed files to the staging area.
To just add a specific file to staging:
git add filename.py
To stage new, modified, or deleted files:
git add -A
To stage new and modified files:
To stage modified and deleted files:
git add -u
This command records the file in the version history. The -m means that a commit message follows. This message is a custom one and you should use it to let your colleagues or your future self know what was added in that commit.
git commit -m "your text"
This command will list files in green or red colors. Green files have been added to the stage but are not committed yet. Files marked as red are the ones not yet added to the stage.
Working with branches
Git branch branch_name
This will create a new branch:
git branch branch_name
Git checkout branch_name
To switch from one branch to another:
git checkout branch_name
Git checkout -b branch_name
To create a new branch and switch to it automatically:
git checkout -b branch_name
This is short for:
git branch branch_name
git checkout branch_name
To list all the branches and see on what branch you currently are:
This command will list the version history for the current branch:
Push & Pull
This command sends the committed changes to a remote repository:
To pull the changes from the remote server to your local computer:
Git is not just for developers. Git is for anyone working in IT - from Systems Administrators to Solutions Architects, Software Engineers, Team Leads, Project managers - should equally learn and understand the workflows in Git.
With the advent of Infrastructure as Code, System administrators and operations teams will be using Git to store code related to infrastructure such as Terraform Configuration files, Ansible Playbooks, Vagrant files, supporting shell scripts.
Git is not just a code repository. Git is where new software is developed. Today most of the popular projects are developed on Github - Kubernetes, Ansible, Terraform, Tensorflow, Helm Charts being a few of the top repositories. All of these projects have extensive documentation built on Github. The Git workflow was built with a collaboration between developers in mind. Code reviews and approvals happen on Github. Github has a Project dashboard that enables project management.
I hope this blog helped you understand Git. You have learned all about Git, you learned various essential topics, like version control systems, centralized version control systems, distributed version control systems, what exactly Git is, benefits of Git, Git workflow, branch in Git, commands in Git, and finally, we busted a few myths on about DevOps.
NovelVista Learning Solutions is a professionally managed training organization with specialization in certification courses. The core management team consists of highly qualified professionals with vast industry experience. NovelVista is an Accredited Training Organization (ATO) to conduct all levels of ITIL Courses. We also conduct training on DevOps, AWS Solution Architect associate, Prince2, MSP, CSM, Cloud Computing, Apache Hadoop, Six Sigma, ISO 20000/27000 & Agile Methodologies.
* Your personal details are for internal use only and will remain confidential.
|AWS Solution Architect Associates|
|SIAM Professional Training & Certification|
|ITIL® 4 Foundation Certification|
|DevOps Foundation By DOI|
|Certified DevOps Developer|
|PRINCE2® Foundation & Practitioner|
|ITIL® 4 Managing Professional Bridge Course|
|Certified DevOps Engineer|
|DevOps Practitioner + Agile Scrum Master|
|ISO Lead Auditor Combo Certification|
|Microsoft Azure Administrator AZ-104|
|Digital Transformation Officer|
|Certified Full Stack Data Scientist|
|Microsoft Azure DevOps Engineer|