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! While you're at it, check out some resources Treehouse students have shared here.

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 Git Basics Branches Beginning to Branch

Brent Brinkley
Brent Brinkley
10,910 Points

Git Remotes Created on Github First

So github has a nice little hosting feature where it will allow you to create a branch to host your project in all it's glory online. The problem is that the branch is created remotely first and I can't figure out how to get to it. I want to pull that branch back into my local repository, so I can make sure the changes I create in master are merged with this other branch and then pushed back up. What's the easiest way to achieve this?

The project I'm referring to can be found here so you can see the different branches: https://github.com/IamEchelon/bootstrap-demo/tree/master

2 Answers

Kristopher Van Sant
PLUS
Kristopher Van Sant
Courses Plus Student 18,830 Points

Ahh, I see. My apologies if I misunderstood. Try git branch -a. You should be able to see it then. It might look something like this...

thelostwayfarer-imac:test kvansant$ git branch -a
* master
  remotes/origin/gh-pages
  remotes/origin/master

If it's there you should be able to switch to your gh-pages branch....

thelostwayfarer-imac:test kvansant$ git checkout gh-pages
Branch gh-pages set up to track remote branch gh-pages from origin.
Switched to a new branch 'gh-pages'
thelostwayfarer-imac:test kvansant$ git branch -a
* gh-pages
  master
  remotes/origin/gh-pages
  remotes/origin/master
thelostwayfarer-imac:test kvansant$ git branch
* gh-pages
  master
thelostwayfarer-imac:test kvansant$ git status
On branch gh-pages

Let me know if that helps at all!

Brent Brinkley
Brent Brinkley
10,910 Points

Awesome that worked thank you! I may be back with more questions lol.

Kristopher Van Sant
Kristopher Van Sant
Courses Plus Student 18,830 Points

Hooray!! Always glad to help :) And keep the questions coming! If you have any more just start a new discussion. Happy coding!

Kristopher Van Sant
PLUS
Kristopher Van Sant
Courses Plus Student 18,830 Points

If you have a new branch you can bring it down locally by using the git pull or git fetch commands. If you have created a new repository on Github and want to bring it locally you would use git clone. I would do some brushing up on Git also. Master is your main branch and is what your pushing your changes to. So this new branch you've created, once it's local would eventually be merged into master.

Check out some of the resources below and they'll show you how to use git fetch and git clone, as well as provide more info on Git and Github.

http://stackoverflow.com/questions/292357/what-are-the-differences-between-git-pull-and-git-fetch

https://help.github.com/articles/fetching-a-remote/

https://help.github.com/articles/set-up-git/

https://help.github.com/

https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

http://git-scm.com/book/en/v2

Brent Brinkley
Brent Brinkley
10,910 Points

Okay maybe I didn't pose the question correctly when I do a pull this is what happens.

alt text

I can't seem to get the gh-pages branch to show up in my local repository so that I can merge it than push the changes back up