Git & GitHub · Lesson 64 of 144
A Teammate's Branch
Checking out remote work.
Alex pushed a branch called gallery, and asked you to take a look. You don't have it locally yet. Getting it takes two commands.

- A teammate pushed a branch
- You don't have it yet
- Two commands
Fetch and switch
First, git fetch. Git reports a new branch, gallery. Then git switch gallery. Git notices there's an origin slash gallery, and creates a local branch that tracks it. Now Alex's gallery page is right here in our folder.
git
git fetch From https://github.com/sam/my-site * [new branch] gallery -> origin/gallery git switch gallery Switched to a new branch 'gallery' branch 'gallery' set up to track 'origin/gallery'. ls about.html gallery.html index.html style.css
Remember
So, to work on someone else's branch, fetch, then switch to it by name. If you make commits on it, git push sends them back to the same branch on GitHub, because it's already tracking it.
git fetchsee new branches
git switch <name>creates a tracking branch
Commitas usual
git pushgoes to their branch
Summary
Fetch, then git switch, and the branch name, gives you a teammate's branch, ready to use. Next, what happens when you and a teammate change the same line.
Key takeaways- git fetch
- git switch <their-branch>
- Tracks it automatically
Next up: Conflicts When Pulling — same line, two people