Git has become part of the toolbox for every software developer. It's success is largely due to its power, flexibility, distributed mode of operation and ability to manage extremely complex projects with multiple developers collaborating on the same code-base. However, Git has a steep learning curve which make it hard for many developers to effectively take advantage. Using Git without understanding of its underlying architecture in detail, can be dangerous. Therefore my argument here is that when starting with Git, developers should invest the time to quickly become expert by understanding how Git is designed, implemented and what each of the commands does in the database. Alternatively, knowing just a little bit of Git can be a problem because you use a powerful tool and can cause a lot of problems for you and the rest of the team.
Reasons to become an expert?
Here are some of the reasons why it pays off to be a Git expert.
Do not cause more harm than good
Some Git commands are doing multiple steps at once and not knowing what exactly happens under the hood can be an issue. For example you can inadvertently merge commits and mess up the commit tree or try to delete commits which are already shared to remote. Another example is committing too much files, which are not needed and complicate the codebase.
Understand the how the Git database works
Because everything in Git is a change in the Git database, understanding its structure and implementation will provide a lot of clarity about Git and help you understand why and how to use certain commands. It will also clarify terms like commit, branch, merge, staging area, working area.
Solve practical issues at work
Having issues occasionally is unavoidable. Everyone can mess things up by executing a command or adding a wrong parameter, but once harm is done an experienced Git user is able to fix the issue right away without propagating it to remote database and team members. Because Git is so powerful, you can fix issues caused by other developers like investigating bugs in the commit history or fixing merge conflicts which are not straightforward to resolve.
Maintaining clean commit log is easier to understand
Being a pro also means that you are able to maintain a clean commit log, which is easy to follow and understand by other people working on the project. Newbies however often produce an intricate mesh of branches, commits which are too many and too disorganized to easily follow historically.
Do not compromise on safety and security
Sometimes Git can be dangerous. For example committing sensitive information like ssh keys, secrets and other access information and then sharing it to public repository.
Collaborate effectively with team members
Using Git for your own project and collaborating with external developers if very different in terms of complexity. You should be able to resolve complex merge conflicts and use tools like pull requests, comments, branches together with others.
Establish yourself as Git expert in the eyes of your peers
Being a Git pro can help elevate you as a valuable team member. You do this by using your understanding of Git to help implement project workflows, solve complex issues and just being the go to person when someone has issues.
How to do it?
Understand the GIT database
Everything in Git boils down to some change in the database. Therefore understanding the database structure and how to manipulate it will be the basis for understanding all commands, tools and workflows. It is impossible to become an expert without this knowledge.
Fix issues when they arise the smart way rather than starting over
When a problem appears, do not look for the quick fix but rather try to understand and fix the problem yourself. An example is when you clone a new project, make a commit and realize the commit has been wrong. Do not start over, but rather try to modify the commit if it is not been shared already.
Use command-line, not GUI tools
UI tools are easier, however it is best to always be able to do everything in the command line. It is always available and will give you much better understanding of Git.
Read the GIT documentation instead of searching for solution online
When trying to do something you don't know how to, go to the Git man pages or original documentation online and try to find the answer there. Searching on Stack Overflow might be quicker, but you will not learn as much for the long term.
Do not execute commands which you do not fully understand
In principle, do not run Git commands which you do not fully understand. Try to read about and see what they change in the database before.
Learn about established branching and merging strategies
There are a number of well established merge and branch strategies, that each team can choose for their software project. Try to learn the major ones and try some.
Online resources
There are plenty of excellent online resources about Git and here are some that I have found useful when learning Git.
Youtube
Git From the Bits Up - https://youtu.be/MYP56QJpDr4
Advanced Git: Graphs, Hashes, and Compression, Oh My! - https://youtu.be/ig5E8CcdM9g
Introduction to Git with Scott Chacon of GitHub - https://youtu.be/ZDR433b0HJY
Official book
Git Book - https://git-scm.com/book
Cheatsheat
Git ready - http://gitready.com/
Opmerkingen