Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools GitHub Basics Working on a Team Workflow Demonstration

Andrew Dickens
Andrew Dickens
18,352 Points

github - fetch or checkout? - video or notes wrong?

in the notes it says In this video, we used git fetch to ensure we had all the branches currently on the remote

but they don't use git fetch, Alyson only uses git checkout 'branchname'

what's the difference? if you use git checkout is it in your local repository?

and then in the following quiz it asks this question

Q: When pulling down a branch for review, what's the correct set of Git commands? A: git fetch; git checkout

Did they forget to us fetch in the video?

2 Answers

Ezra Siton
Ezra Siton
12,644 Points

When pulling down a branch for review, what's the correct set of Git commands?

In general, the text of this Q is not so clear (In the video the steps related to clone-repo with branches).

The answer:

git fetch (Downloads commits, files, and refs from a remote repository into your local repo.)
git checkout (navigate between the branches created by git branch)

Full working flow example:

A. remote (Github site)

Go to your repo Url - pencil icon (Edit) - and edit the readme file (add "hello world" text ==> Commit changes to? `create new branch" "branch-helloworld" - click "confirm"

You are now inside Open a pull request page - create pull request named "hello world pull request".

B. Local (Terminal code)

Go to your local folder.

Where is the branch?

Helper - Run: [git branch --remote: list out remote branches]

git branch --remote

You won't find branch-helloworld on the list (The remote branch From step A)


1. Part one of the answer


git fetch

(New branch added to you local from the remote repo)


Run again:

git branch --remote

Now you find branch-helloworld in the list :)

2. Part two of the answer

The git checkout command lets you navigate between the branches created by git branch.


git checkout branch-helloworld

Switched to a new branch 'branch-helloworld' Branch 'branch-helloworld' set up to track remote branch 'branch-helloworld' from 'origin'.

Last step

commit changes to branch-helloworld.


git add . 
git commit -m "add change to branch-helloworld"
git push origin branch-helloworld

Go to github repo - go to branch-helloworld and you find new commit named "add change to branch-helloworld"

Chris Komaroff
Chris Komaroff
Courses Plus Student 13,673 Points

It seems "git checkout" was used here. Teacher's notes here do not reflect video. Maybe "git fetch" or "git pull" would work. This is first example of "git checkout" I have seen that checks out files from remote repo. But a good lesson anyway.