Tips and Best Practices for version control using GIT

Tips and Best Practices for version control using GIT

In this article, we will discuss some of the tips and best practices for version control using GIT

By far, Git is the most widely used version control system in the world. It is actively maintained OSS project. I don’t know how many of you know but the project “Git” was originally developed by Linux Torvalds (the famous creator of Linux Kernel) in 2005. A huge number of projects including commercial projects make use of Git today.

Many fantabulous online git hosting services like GitHub, GitLab, bitbucket etc. are built around it. Unlike earlier version control systems like SVN, Git is a distributed version control system and has been designed with performance, security, and flexibility in mind. Like every technology, there are tips and best practices for version control using GIT.

Tips and Best Practices for version control using GIT

Tips and Best Practices for version control using GIT

Let’s focus on some of the tips and best Practices for version control using GIT

Test the codes before you commit

Having your code thoroughly tested is important when it comes to push/share your codes with others.

Usage of branches

One of the powerful features of Git is its branch feature. In order to avoid mix-ups of multi-developer/department environment and, we should use branches to avoid confusion and overlaps. It can be named as you like according to your workflows like development, QA, new changes, bug fixes etc.

Commit Related Changes

A commit is considered as a wrapper for changes. Fixing two different issues should produce two separate commits. These small commits help in easy code management, a better understanding of the changes and roll them back if something is wrong.

Commit often

Committing the changes often keeps your commits small and maintain related changes. It also allows sharing the code more quickly and frequently to others, integrate with the other parts of the code, and avoid merge conflicts. Large size commits often create chaos and makes it hard to solve conflicts.

Write good commit messages

Always write a good summary of the changes made (50 characters will be a good value). Try to include the motivation of the change and how was it implemented.

Avoid committing half-done work

Rule of thumb, commit only what’s completed. It should not be a very large feature but commit in small logical chunks that is easily understandable. Don’t make commits just for the sake to complete the day. If you still look to commit an unfinished code, use git stash feature.

Don’t use Git as your backup system

Just don’t upload unrelated files and junks to git to use it as a backup system. You should pay attention to make all commits semantically and ethically correct.

These are some of the tips and best practices for version control using GIT. It is not only for Git, just we are paying more attention to Git. Even, version control is used, all the developers or common-minded people should have an agreement on the workflow internally and follow it.

Git has become an essential part of DevOps and every developer, administrators should know this on-going. You can find more details about the Git project here and detailed documentation is available in the documentation section available here.

Healthy discussions are always welcome!!!

Check out the links below for the other articles related to Git

Git Cheat Sheet