Fetch a remote branch in Git
The Problem
In my Git repository, how do I fetch a branch from a remote to start working on locally? There is no equivalently named branch in my local repository.
The Solution
We can do this using git fetch to retrieve the remote branch and git switch to work on it locally. First, fetch the remote branch:
git fetch remote-branch
Then switch to it:
git switch remote-branch
Under the hood, this command will create a local branch named remote-branch, which tracks the version of remote-branch on the repository’s remote, and check it out. We can then make commits, push them, and pull others’ commits from this branch as usual.
Considered "not bad" by 4 million developers and more than 150,000 organizations worldwide, Sentry provides code-level observability to many of the world's best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.