Question:

What is git?

Git tracks all the changes you make to your code so you can see what changed, when it changed, and roll back mistakes. It’s like having an unlimited undo button for your entire project, but way more powerful.

When you’re working on code, you make changes constantly. Sometimes you want to try something new without breaking what’s working. Sometimes you need to see what the code looked like last week. Sometimes multiple people are working on the same files at once. Git solves all these problems by keeping a complete history of every change ever made.

The way git works is through commits. Every time you finish a chunk of work, you create a commit with a message describing what you changed. Git saves a snapshot of your entire project at that moment. You can go back to any commit later to see exactly what your code looked like. You can compare commits to see what changed between them. You can even undo commits if you made a mistake.

Git also has branches, which let you work on different versions of your code simultaneously. You might have a main branch with your stable code, and create a new branch to experiment with a feature. If the experiment works, you merge it back into main. If it doesn’t, you delete the branch and your main code is untouched.

Most developers use git with a hosting service like GitHub, GitLab, or Bitbucket. You keep a copy of your code locally on your computer and push changes to the remote repository on these services. This acts as a backup and lets other people access the code. When multiple people work on the same project, they each pull the latest changes, work on their own branches, and push their changes back.

Git has a reputation for being hard to learn, and the basics are straightforward, but some of the more advanced features take time to understand. Commands like merge, rebase, cherry-pick, and reset can be confusing at first. But you don’t need to know everything to be productive. Most day-to-day work uses just a handful of commands.

I’ve been coding professionally long enough to remember using CVS for version control, and then Subversion when it was the hot new thing. But git came along and was so much better that it quickly became the standard. Now so many things are built on top of git that I’d be surprised if we ever switched. I don’t even hear anyone talking about alternatives.

You might also like