Avoid these 5 mistakes while using GIT as a newbie

Avoid these 5 mistakes while using GIT as a newbie

Git can be a tricky technology in the tech world to understand and use correctly. Let's look at some mistakes beginners can make while using git and while they should avoid them.

1. Deleting The .git Folder

As stupid as that may seem, it is actually possible to delete the .git folder in your project by accident. This folder contains all the information Git needs to keep track of changes in your project. This means deleting this folder essentially stops git from tracking your project and hence destroys the repository

2. Omittng A .gitignore File

This file is used to tell GIT to not track some files or folders in your project. This comes in handy when you have some large project files in your project you may not want to keep track of because they can be generated anytime (eg node_modules) as well as sensitive data you may not want to share with anyone.

3. Grouping Multiple Unrelated Changes Into One Commit

As a beginner in GIT, it's difficult to see the use of GIT right away which leads to making "lazy commits". These are commits you probably make after realizing you've been coding for so long and you need to push your code to GitHub, so you bundle all your changes and label under a single commit. This is a bad approach to using git because it would be difficult to know what specifically changed with each commit which heavily destroys the purpose of git

A good rule of thumb is to make Atomic Commits. This is an ideology that a commit showed only contain a single change. You can do this by making commits after every little feature you build in your project. This way you can easily tell what changes you made at each commit stage of your project

4. Not Using Branches For Experimental Code

Trying out experimental code is like an everyday thing for developers and as a beginner chances are there are new things you might want to try out in your project (probably improving a course project). Too many times we just carry on with our experimental changes on our main branch which then makes it difficult to revert if our changes don't work properly. This is one of the areas where git branches shine. Creating a new branch for an experimental feature preserves your main project and then you can make all the changes you want on that "feature" branch. If after a while you don't like the changes you can switch back to your main project and everything should be just as before!

5. Memorizing Git Commands

This one is a bit controversial and a little silly I know :). However, many times as a beginner it becomes a big problem when you try to memorize all the git commands you learn from a course or tutorial, which is why I advise you don't. What you can do instead is take note of the commands you use most often, write them down if you have to so you can look them up each time you need them. You could also google more commands when needed. With time, the commands would become second nature to you and you would have saved yourself from a lot of memory trouble. lol.

So there you have it. I hope you enjoyed this short article. Please give it a like if you did and you can comment below your struggles with GIT. I would love to hear from you. With that said, it's time I stop talking and I will see you on the next one.