Tracking in git

git for Beginners

Published: May 26, 2020

When you're working with git, you may run across the term "tracking." I'm going to explain what that term is and why it matters.

This post is part of a larger series on git:

Let's jump in.

git is a big part of development because it's one way that developers work together. If you're not sure what git is, why you would use it, how to get it installed, check out some of the other videos in this series.​

So, tracking...

It's pretty simple. Tracking is when you have a local branch that has a direct relationship with a remote branch. If you are tracking a branch, you can use git push or git pull without having to type everything out ... git push origin new-branch. It already knows the correlation between the two branches, so there's no need to be verbose.

When you clone a repository, usually it will establish a tracking relationship between your local master branch and remote master branch automatically.

If you want to download the code from a remote branch and set up tracking all in one swoop, you can use:

1 git checkout --track origin/branch-name

This will create a new branch on your machine with the same name, download the code from the remote repository, and then move you to the new branch on your machine.

Technically, you could set up tracking for a branch on your local machine to point to a branch with a different name on your remote repository...but I wouldn't recommend it. You'll only create confusion.

Horizontal Divider


This industry moves fast, but you can stay up to date:

Receive a weekly email of the Internet's best from articles, to tutorials, to pro tips.