Please enable JavaScript to view the comments powered by Disqus. Git! An Important DevOps Tool

 

 

 

 

 

 

Git! An Important DevOps Tool

NovelVista

NovelVista

Last updated 10/06/2021


Git! An Important DevOps Tool

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:

  • Store your source code
  • Track changes in your source code
  • Anybody can access the source code if needed.

Why is it so important?

If you are a coder/ programmer/ developer, you have to know Git.

  • Most importantly, your code is saved for life. You can't lose it.
  • Suppose, you and your friend are working on a project/software and want to make some modifications, how would you do so?

Git allows developers to download a new version of the software/project/code/file, make changes, and upload the newest revision.

  • You can track every change in the source code and check how it looked 1 day, 1 month, 1 year, or 10 years before.
  • You can look for people working on similar projects and work with them.
  • Contributing to an open-source is such great exposure to one. It makes you future-ready for the Tech industry.

Git key concepts

Git key terminologies include:

  • Version Control System: Git helps maintain various versions of the codebase at different stages of the development lifecycle. It is also called a source code manager.
  • Commit: When a developer makes code changes, the changes are saved in the local repository. Every commit saves a copy of the changed/added files within Git.
  • Push - This sends the recent commits from developers' local repository to a remote server like GitHub, GitLab, or BitBucket.
  • Pull - This downloads any changes made from the remote Git repository and merges them into the developers' local repository.
  • SHA (Secure Hash Algorithm): This is a unique ID given to each commit.
  • Branch: When you diverge from the mainline of software development and continue to work/code without messing with the main/master development line.

Role of GIT in DevOps

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.

Most popular Git solutions

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.
Comparing Confusing Terms in GitHub, Bitbucket, and GitLab | GitLab

Difference between Git and GitHub

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.
git and github

Commands

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.

git init

Git add

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:

git add.

To stage modified and deleted files:

git add -u

Git commit

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"

Git status

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.

git status

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

Git branch

To list all the branches and see on what branch you currently are:

git branch

Git log

This command will list the version history for the current branch:

git log

 

Push & Pull

Git push

This command sends the committed changes to a remote repository:

git push

Git pull

To pull the changes from the remote server to your local computer:

git pull

A few myths about Git

Myth 1: Git is only for Software Developers

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.

Myth 2: GitHub is just a codebase/repository

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.

Conclusion

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.

 

Topic Related Post

DevOps for Mobile App Development
Top 8 New Trends in DevOps Worth Checking out in 2021
A brief overview of Bitbucket

About Author

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.

Tags

 
 

SUBMIT ENQUIRY

* Your personal details are for internal use only and will remain confidential.

 
 
 
 
 
 

Upcoming Events

ITIL-Logo-BL
ITIL

Every Weekend

AWS-Logo-BL
AWS

Every Weekend

Dev-Ops-Logo-BL
DevOps

Every Weekend

Prince2-Logo-BL
PRINCE2

Every Weekend

Topic Related

Take Simple Quiz and Get Discount Upto 50%