this post was submitted on 18 Jul 2023
12 points (100.0% liked)
Ask Experienced Devs
1248 readers
1 users here now
Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Could you elaborate?
Using git effectively is like heading superpowers in programming compared to not having any version control as it allows you to do a bunch of things that would be very complex otherwise. Ex:
When writing code, if you only commit “working code” it’s easy to check at any moment what changes you’ve done in the last chunk with git status. Even most IDEs nowadays highlight the changes lines with some special marker. This allows you to know every detail of what you’re doing without filling your working memory tracking files yourself.
Seeing the history of your project allows you to track any of your workmates changes as well, you can always check who last changed a line of code with git blame (IDEs also make that easier), your commit text will usually tell you what is that change about.
It allows you to quickly try something out and if halfway through it you realize it won’t work, just discard the changes and restart using a different approach.
It allows you to have multiple “work-in-progress” features simultaneously in different branches, which makes it possible to do hotfixes on production code even though the development branch is way ahead.
It lets you break a big feature into multiple small commits and later on it’s easy to gather multiple commits in a branch into one big commit if it makes sense (let’s say you were not sure how you’d do it at first and kept changing something back and forth trying different things. Once you realize what the best approach is, you can turn all those changes into a single one).
Committing often allows you to “revert” any change in the future very easily, in a non destructive way.
So a lot of advantages of git require also to use it alongside best practices, such as the different git branching models. It doesn’t matter if you prefer using the command line or some visual client, just the fact of understanding how you’re using it makes a lot of difference.