Learn Git with Real Projects

Learn Git with Real Projects

Git is a powerful version control system that helps developers manage their code and collaborate effectively. It can seem daunting at first, and many new developers put off learning all but the basics, but understanding git is an essential part of modern software development.

My aim with this post is not to write up yet another git basics tutorial. There are plenty of those on the internet already, I recommend starting with your favorite tech YouTuber or learning platform. The aim here is to give you some ideas about how to apply those skills, so you can practice and improve them in a meaningful way. So then the question remains, what is the best way to learn to use git and really walk away with a meaningful understanding of what you’ve learned?

To me, the answer is to really use it. I’ll go over some different options available today, and weigh the pros and cons of each one, then I’ll cover ways to dig even deeper after you are comfortable with the basics.

But first…

Why Learn Git with Real Projects?

Learning git can be intimidating, especially if you’re new to coding or version control. It’s easy to get lost in the jargon and syntax of git commands, without understanding the context behind why they exist in the first place.

Personally, I think that there is no better way to understand that context than to use Git in a real project. By using it in the context of a project, you’ll learn everything that a tutorial would have taught you and you’ll come away with a much deeper understanding of what you’ve learned and how it can be applied to other projects.

How To Get Started?

There are actually quite a few avenues for you to start learning depending on your current situation. I recommend taking a couple of different approaches, as each scenario will help you to hone different skills.

Tutorials / Personal Project

A great way to safely familiarize yourself with Git basics is to use it to track side projects, school projects, and tutorials.

I’m not talking about following Git tutorials, I mean follow a tutorial where you are learning something unrelated to Git. Most coding tutorials don’t bring up Git because doing so would mean they’d need to explain what it is and how to use it, and that would take away from the topic that they want to teach. Just because they don’t mention it doesn’t mean you can’t use it though. I suggest creating a repo for any tutorials that you run through and making regular commits as you work through them.

Similarly, if you are in school and working on class projects, or if you have a personal side project in mind, just track it! It will only help you to have a repo set up somewhere. If you can’t or would prefer not to make your project code public, both GitHub and Bitbucket offer free private repositories. I use them all the time!

Not only does this approach teach you the basics and help to reinforce your memory, but you will have your work backed up and you will have a portfolio of work ready for potential employers to review.

Pros

  • Safe and easy way to learn the basics
  • Reinforcement through repetition
  • You’re probably already doing tutorials, school projects, etc
  • Generates a portfolio of work for you
  • You’ll be able to easily come back to your projects for reference later

Cons

  • You get no experience working with other people – A huge part of Git is about collaboration
  • If you are brand new to Git, this may slow you down since you are effectively learning two things at once
  • You won’t get any experience with code reviews or Pull Requests

Group Project / Side Business

This approach is similar to a personal side project but is more focused on building your ability to work with git in a team setting. This is a skill that is invaluable to build, since there are few times in the real world you’ll be the only person working in a repository.

If you are in school, or if you have any like-minded developer friends, a low-pressure learning-centric project is a great way to improve your dev skills and simultaneously improve your git skills.

If you are already working in the industry, or if you aren’t a fan of unpaid side projects, you could try your hand at starting a side business (think WP Theme/Plugin, SaaS project, etc) with another developer or two, provided you have an idea that you feel will be worth the time investment.

In either case, the goal would be to start a development project with at least one other developer and use git for your version control, code reviews, and release workflow. This will undoubtedly level up your ability to work with a team and, depending on how deep down the rabbit hole you go, may even push you outside of your comfort zone a bit.

Pros

  • Lower pressure environment than a workplace
  • You’ll encounter real-world challenges
  • Opportunity to work in a repo as part of a team
  • May push you outside of your comfort zone (a great way to learn!)
  • Accountability will push you through roadblocks

Cons

  • Learning with other beginners may lead to inefficiency or a messy commit history
  • Accountability will contribute to stress
  • Requires other people

Non-Code Projects

Do you write poems or stories? How do you keep track of your favorite recipes? Do you write scripts for YouTube videos?

All of the above are perfectly acceptable uses for Git, albeit somewhat unconventional ones. Even better if you are working on these with others.

Also related to this category – track your PC configuration files in Git. Many people track their bash, or vim configuration with Git. You can also track Apache, Nginx, PHP configs, or any other configuration files that you want to back up and/or have access to when away from your PC. Just make sure you don’t track any sensitive information!

Pros

  • Safe and easy way to learn the basics
  • You’ll have backups of whatever content you choose to track with Git
  • There is a plethora of content you can track this way

Cons

  • You get no experience working with other people – A huge part of Git is about collaboration
  • If you are brand new to Git, this may slow you down since you are effectively learning two things at once
  • You won’t get any experience with code reviews or Pull Requests
  • Not using Git in a conventional way

Open-Source Contribution

Depending on who you are, and what stage of your development career you are in, this is arguably one of the more intimidating suggestions. That being said if you look past the occasional rough community, the open-source community is generally extremely friendly and tends to welcome new developers with open arms. Diving into the open-source world would probably require its own post, but the most important thing to remember is to follow the community guidelines and start small with issues you feel comfortable taking on.

Open-source contribution is about as real-world as any project you’d take on in a job and, if you are contributing to a project that you want to see succeed, it can be an extremely fulfilling way to improve your skills. You also get the satisfaction of being able to include your contributions on your resume. You’ll likely be working with many different developers of all different skill levels, and you will learn real-world git workflow strategies.

There are tons of resources out there for anyone interested in starting with open-source development, but one that I like to direct people to is First Timers Only. There you’ll find a plethora of resources to help you get started and find projects that you are interested in.

Pros

  • Real-world experience
  • You get to work in a repo with other developers of varying skill levels
  • You get to contribute at your own pace
  • You get to help build projects that you believe in
  • You will likely learn lots of different technologies

Cons

  • Can be intimidating at first
  • Some communities may not be friendly
  • Can be fairly bureaucratic
  • Generally, you will be volunteering your time

On the Job

Finally, you can practice at work. Contrary to what hiring managers would lead you to believe, you can get a dev job with little to no git experience. I have worked in whole teams with a mostly rudimentary understanding of git. Part of why I wrote this article is that I think there is a distinct lack of meaningful git education coming from boot camps and tutorials, and there isn’t much information out there about how to improve your git skills in a meaningful way.

I do think that there is a tactful way to do this which will help to protect you from doing anything that results in a visit from an angry senior dev. The general rules of thumb in this scenario:

  1. If it feels wrong, it probably is – If you feel like you are fighting with git to do something, ask the resident git expert for a second opinion.
  2. Avoid git push --force – If you are force pushing it’s usually because you are replacing a commit or the details of a commit on the remote. This has the potential to break things for other team members. If you are in a position where a force push is necessary, make sure you reach out to your team lead for guidance first.
  3. Merge in your base branch frequently – If you are working on a feature branch, especially if you are working on one for a long period of time, merge your base branch in from time to time. This has many benefits, namely: merges back to the base will have fewer and more manageable conflicts, and code reviews/testing will more accurately reflect behavior in the most recent release.
  4. Ask if you are stuck or unsure – There is no shame in asking for help if you get stuck, or if you aren’t sure about something, just make sure you do it before you push to your production branch. The worst that happens is you get a second opinion on your situation. If asking for help is taboo in your workplace, you might want to look for a new job.

Pros

  • Real-world experience
  • You get to work in a repo with other developers of varying skill levels
  • Learn while getting paid
  • In most cases, your co-workers will want to help you learn and succeed

Cons

  • Lack of knowledge may make you less productive
  • Higher stakes
  • Possibility of breaking builds or causing issues in your work’s repo
  • Not every company has a knowledgable team, or organized git workflow

Further Learning

If you feel that you have a good working knowledge of git but you are looking to improve your skills further, the above suggestions still work. However, they may not push you to learn quite as much as when you are starting out. One way I like to improve my skills when I’ve reached the point where I start to feel a little too comfortable is to intentionally find ways to push myself outside of my comfort zone.

I don’t recommend doing experimentation at work, but you can always set up a side project to work with aspects of git you are less familiar with. Some random ideas in no particular order:

  • Try setting up a repo and experiment with git rebase until you feel like you have a good understanding of how it works. Make sure to try git rebase -i and try to manually pick and squash some commits
  • Try generating yourself some release packages using git archive . See if you can remove development-specific files from your release without removing them from your repo.
  • Ever used git bisect and git blame to pinpoint when and where a bug was introduced? If not, give it a try.
  • Try to get a list of only the filenames that have changed in the last 3 commits in your repo
  • Try to create a zip file containing only files changed in the last commit
  • Experiment with changing a commit using git commit --amend
  • Try using git grep to find occurrences of words in your commit history
  • Try getting the commit history of a particular file with git log
  • Experiment with git cherry-pick in a safe environment

Comments

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *