Skip to main content

Git commit best practices for beginners

Git commit best practices
               
 If you are a recent college grad, you are going to use version control systems like git, mercurial day in and day out as you progress through your career. So I thought I can share you some knowledge about using git commit and its best practices.

Treat commits religiously 

Every git commit you do is basically a track of the progress of the product. A git commit should basically contain a feature or a bug fix. So commits like "changed a to b", "Removing div element." is not really a progress. Going forward you will need more commits like "ABC class added", "XYZ Function Implemented", etc.

Avoid repeated/duplicate commits

Sometimes, without your knowledge, you would tend to commit a change multiple times. So it is always good to crosscheck the logs using git log before you push. 

Test before you push

This is mainly because the changes you made could affect any other feature. So before you commit and push any progress, testing the feature is a must. If the commit may not be right and still you want to push it, you may consider using git stash feature.

Git repo must contain only source files

Sometimes after you test, binary files like "*.class" or CMake build directory will be present and it must be removed before the commit. You should always keep in mind that the repo is only for source not for binaries :)

Commit message 

In case of committing multiple features/bugs in a single commit, you can mention the changes in a numbered list like 1) ..... 2) .....

Use git in command line more

By using git in command line, you will get to understand how the version control actually works. GUI makes things easy, but command line makes you understand it.



I found this funny git meme. Hahaha.

       If you are doing something wrong with git commit so far, no problem. It is never too late, start reflecting the learning from today. And there are tons and tons of best practices available online. I'm sure you will get used to git. If you have any other git commit best practices to share, please do not hesitate to post it in the comment section below.

Comments

Popular posts from this blog

Sachin Tendulkar's legendary journey

"I see myself when I see Sachin play"  -Cricketing legend Sir Don Bradman Sachin Ramesh Tendulkar, had represented India at the age of 16. Rather than asking 'How old are you?', people who were longing to query his age would have asked him 'How young are you?'. Such a prodigy he was and still is one. He was given his first international cap on 15 November 1989 and exactly 23 years and 364 days later, he played his last international cricket match for his nation and on a combo, it was his 200th test match.              Sachin has scored over a 34,000 international runs, and there are no exclamations for that huge milestone after describing him as a prodigy. But still seeing another cricketer of his quality and matching his frequency, is very far away from my eyes. But who knows he might be somewhere playing cricket in schools, or schooling in kinder gardens, or building blocks in play schools, or might even be an unhatched embryo.  ...

Object oriented SDK development

If you are someone who is into object oriented SDK development and looking for some best practices on API design, I have got you covered here. I have used C++ as the base to explain the core. OpenCV is one of the frameworks I have come across that does an exceptional job in providing classic and productive APIs in C++. Let's not waste time an quickly jump into the best practices of object oriented API design. Design easy-to-read API names First and foremost thing to consider in an object oriented SDK is the API name itself. Your API names should reveal everything. Keeping APIs as small as possible can be a difficult task but that is what you should deliver. The API should do what the name says. Nothing more. Nothing less.  Write your headers and review it Before you jump into development, it is important to code what the user wants. To have a crosscheck on that, write a header file(.h or .hpp) containing the public/private functions and data members. In this process, ...

The art of sleeping

     They say that living is an art but I am starting to think that sleeping is an art, too! It’s just not as easy as it was when I was a kid. Being an adult, sleep is not just a sleep. It encompasses of a mixture of various feelings that we undergo in the day life. A happy sleep requires 3 things. i.e., satisfaction at heart, peace in mind and the harmony in soul. But I say, the foremost requirement for a good sleep is a good day at the work. When you gave your all, at the work and go to the bed, I bet you it is the most amazing feel in the world.     Now, why is sleeping an art? I had a research on controlling the sleep. And to my fortune, it paid off. The research was about the concept of self alarm. Yes, an automated alarm within us which would wake us up from the sleep. The idea was very simple. I had an inner consiousness while sleeping which kept an indegenous alarm within me which would wake me up around the intended time.(No more ringing bells or 6am ...