Git Etiquette 101: Best Practices for Collaborative and Efficient Code Management

Search for a command to run...

No comments yet. Be the first to comment.
One of the methods of abstraction is to integrate another service. But can you trust someone else's service? Third-party APIs are notorious for failing at the worst possible time. Over time, I ended u

A race condition can hit you anytime, you think it won't because your system isn't that big, or doesn't process a lot of requests, but it will happen, and when it happens, you will feel a bit silly ab

The world is going through a tumultuous phase, but that doesn't stop the progress of humanity. Things go on, people move, prices fluctuate, we eat fruit and live a healthy life. April is hot, so hot,

Well, I celebrated my birthday. :P I worked on a functionality end to end using AI. It was a simple feature and AI wrote everything correctly in a single pass. I used Codex. After that, I had to ask i

Let me think. So I worked on a new functionality and raised a PR in just 2 days for the whole end-to-end correct flow. I did not focus much on performance because I wanted to first get it right and th

Git is a powerful version control software that has become the industry standard for developers worldwide. In fact, being proficient in Git is more than just a useful skill – it's an essential tool that can help every developer become a better developer.
The aim of this blog is to introduce you to the best practices for using Git. While you may not always adhere to these practices when working on personal projects, they become crucial when working in a large team setting. Moreover, following the best Git practices is essential when solving coding assignments for job interviews. It helps showcase your proficiency in Git and demonstrates that you can work collaboratively with others while maintaining clean and organized code.
Create branches for new features, bug fixes, and experiments:
Feature branches: feature/{short-description-of-the-feature}
example: feature/add-social-login
Bug fix branches: bugfix/{short-description-of-the-bug}
example: bugfix/fix-login-api-error
Experimental branches: experimental/{short-description-of-the-experiment}
example: experimental/test-new-database-schema
Keep each branch's scope limited:
Let's say you have implemented an update profile API, then make sure the changes on the branch are only limited to the profile update. Trust me it will make your life easier in the long run.
Write clear and concise commit messages:
Make sure your commits make sense, make it more descriptive.
Example: Instead of "Update profile", write "Add function to check if profile updation is valid"
Keep your commits small and focused:
Small and focused commits make it easier to track the progress of your project and understand what changes have been made. It is easier for your team members to review your code changes.
Use the imperative tense in commit messages:
Use imperative verbs (e.g. "Add," "Fix," "Refactor") to describe the change you made.
Instead of "Refactoring navigation menu to use responsive design" write this "Refactor navigation menu to use responsive design"
I am not going to go into the debate of merge vs rebase. DYOR here.
If you want to explore the power of git, then you can check out git hooks.
Conclusion
In conclusion, using Git is an essential skill for modern software development, and following best practices can help you and your team work more efficiently and effectively.
Also, give read my blog for best readme practices.
Cheers.