Get new issues of The GitHub Insider in your inbox. Sign up now →
The GitHub Insider
Git good, real good ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ 

Have you ever wondered what in the world Git is and how to “git” good at it? (Sorry, I had to do it.)

In this edition of The GitHub Insider, we’re gonna “git” in the weeds, break down the basics, and toss some tips and tricks your way. Whether you’re a seasoned pro or new to coding, this newsletter will have something for you. So, let’s “git” down to business. (Okay, that was the last one, promise.)

Git 101 🤓

Before we get to the tips and tricks, let’s quickly cover what Git is. Git is the most widely used Version Control System (VCS) in the world—meaning it tracks the historical changes to files.

As legend goes, in the early 2000s, the Linux project used a commercial tool called BitKeeper for version control. However, a licensing dispute arose, and the free version for Linux developers was revoked. This spurred Linus Torvalds, the creator of Linux, to develop his own version control system: Git. Thus, Git was born out of necessity and a desire for an open-source alternative.

Git has lots of benefits for devs, including:

Here are some valuable terms to know as you start using Git:

💡 Want some more info on Git and how to install it? Check out this blog post (you won’t be disappointed).

Now, it’s time for those tips and tricks 👀

1. Make sure you configure Git 🧑‍💻

Once you have Git installed, personalize it. Use git config to set your username and email. This lets Git understand who you are, and therefore can track your contributions properly.

2. Create a new Git repository ➕

The git init command is used to initialize a new Git repository. Think of it as turning on a Git switch. Let’s say—for example—you create a new folder with the terminal command mkdir project1. You can go into project1 by running cd project1. In its current state, project1 is not a Git repository. If you want this folder to be a Git repository so you can track all the changes you make, type git init and run the command. Now that folder is a Git repository and will track all your changes.

3. Shortcut your workflow with Git aliases 🏃

Tired of those long-winded Git commands slowing you down? Git lets you create custom shortcuts called aliases. Imagine zipping to the master branch with a quick git co master instead of the entire command. Open your terminal and type: git config –global checkout and run it. Now, "co" acts as your alias for "checkout", meaning you can type coco instead of checkout."

4. Master the branching basics 🤝

You can create separate branches for new features, bug fixes, or experiments. This isolates your changes and lets you work on your new idea without breaking the main codebase. Only when a feature is complete and tested should you "merge" it back into the main branch. To see a list of the branches you have, you can type git branch.

5. Get back to the main branch ↩️

You can use the git switch command to navigate to your main branch anytime. In your terminal, type git switch main to return to the main branch.

6. Embrace the power of commit messages 📧

To “commit” a change means to store a version of your project in the Git history. Before committing, use the git add command to select which specific changes you want to include in the commit. Provide a clear and concise message describing the changes you made. This message is crucial for understanding the project's history and collaborating effectively with others. When you run git commit, Git takes the staged changes and your message, creates a new commit object, and stores it in your local Git repository.

7. Push it real good!🫸

The command git push tells Git, “Thanks for tracking these file changes. Now I want to upload these changes into the main project file.” When you push your changes, you are essentially updating the remote repository with commits that have been made in your local repository.

There’s also the git push --force command, which forcefully rewrites remote branch history with your local commits, potentially overwriting others' work. ❗ This command should be used with extreme caution. ❗ For example, if you're working on a solo branch and accidentally push something sensitive, you can use git push --force to remove it after fixing your local commits.

8. Copy projects to your local machine 👬

Need a copy of a remote project folder on your laptop? Git can help. Use the git clone command followed by the URL of the remote repository (like copying a link and pasting it). This creates a local copy, called a clone, that you can work on.

9. Autocorrection with Git ⌨️

We all make mistakes—and Git offers built-in autocorrection to help you with typos in commands. Imagine you want to switch to the main branch, but accidentally type git checkout master. Usually, Git will tell you this command doesn’t exist. With Autocorrect enabled, instead of suggesting an alternative subcommand, Git now just runs the top suggestion. Follow these steps to configure autocorrection:

Use the git config command with the following syntax: git config --global help.autocorrect <value>

Replace <value> with your desired behavior:

For a default delay with suggestions, use a value between 0 and 50 (eg, git config --global help.autocorrect 20).

10. Navigating the commit history 🔍

A clear commit history in Git is like a detailed map of your project's evolution. Use git log to view the commit history. You can customize the output with various options, such as --oneline, --graph, and --all. By combining these options, you can effectively navigate your project's history and pinpoint the exact changes you're interested in.

Master Git like a pro: bonus tips and resources

Want to take your Git skills to the next level? We've got you covered. Watch this video and transform into a Git power user. Or you can dive deep into this treasure trove of super helpful tricks in the git-tips repo. Our GitHub Foundations course is also packed with everything you need to know about Git and the benefits of using GitHub as a collaborative platform.

And if you made it this far…

🎉 Congratulations! 🎉 You've learned the basics of Git. Now, it's time to unleash its full potential with GitHub Actions! This powerful feature integrates seamlessly with Git by allowing you to define automated workflows directly within your Git repository.

Here’s a snapshot of what you can do with GitHub Actions:

Thanks for reading and being the best subscriber ever ❤️, and until next time, keep branching out those development skills. (Get it?)

Get started with GitHub Actions

✨ This newsletter was written by Sara Verdi and produced by Gwen Davis. ✨

More to explore 🌎

Join our GitHub Actions conversations 📄

Visit our community forum to see what people are saying + offer your own two cents.

Visit now

Take our open source survey 💡

We’re working with the Linux Foundation and researchers at Harvard University to learn more about how organizations fund open source projects.

Take the survey now

Stay updated on GitHub products 📦

Discover the latest ships, launches, and improvements in our Changelog.

Explore now

Connect with us at an event near you 🫱🏻‍🫲🏾

Are we in your neighborhood? Let’s meet up.

Find event

Subscribe to our LinkedIn newsletter 🚀

Do your best work on GitHub. Subscribe to our LinkedIn newsletter, Branching Out_.

Sign up now


The world’s leading AI-powered developer platform.