Rolepath

Using Git in the Real World

Introduction

Git basics are very straightforward, but it sometimes feels like a bottomless pit when you find yourself on the wrong side of a confusing error situation. It’s doubly frustrating because you think that messing up or trying the wrong solution can lose data. It’s actually very hard to “lose” data with Git but it can certainly be hiding somewhere you wouldn’t think to look without an experienced dev poking around.

The thing about Git is that, unless you’ve got a seriously impressive memory, you can’t just master it by reading about it; you need hands-on practice! For example, find a problem you want to fix, run into a merge error, and then dive into Google to learn a new Git technique along the way to help you fix that problem.

To help you out, come back and refer to this lesson again when you’re in trouble. We’ll first have a reminder about commit messages, then cover a real-world example of a GitHub workflow used on this very project.

Lesson overview

This section contains a general overview of topics that you will learn in this lesson.

  • A reminder about commit messages.
  • Using Git to make open source contributions.

Commit messages for collaboration

Before we dive into workflows, take a minute to remind yourself about good commit messages. You can check the Commit Messages lesson for a reminder. This is a good time to draw particular attention to Conventional Commits, a standard for commits that is gaining more and more popularity for collaborative projects. It helps to make sure your commit message gives a clear description of its purpose to anyone reading. Going forward, you may like to implement these (if you aren’t already!), or at least be aware of them for when you read other repos.

Workflow diagram

Here is a visual representation of the workflow with Git and GitHub that illustrates how changes flow between repositories during collaboration.

git fetch upstream/main
git checkout your_branch_name
git push origin your_branch_name
Create Pull Request to Upstream
Maintainers Merge PR to Upstream
Upstream Repository: TheOdinProject/curriculum
Local Repository: main
Local Repository: your_branch_name
Your Fork on GitHub
Pull Request on GitHub