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 Working With Remote Repositories GitHub

Nitin Chauhan
Nitin Chauhan
444 Points

Remote Origin?

Does pushing changes to Github make Github as "origin" for our local master? I ran git remote on the local master and it showed two remotes --

  1. The remote we made on our local machine for the original master.
  2. origin -- my question is regarding this origin.. Is this Github?

Also, what is the difference between git push and git push -u?

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Origin is the way github links to your account sand remote repository. So you will set up your remote repository on Github and then Github will give you instructions as to how to push your branch to the remote repository. Once done, your repo is linked to github for as long as it exists there.

git remote origin master

Once done then I can then set up more branches and push them from the command line and it will the show up accordingly on Github.

git push --set-upstream nameOfBranch

And once set up, it's as simple as doing

git push

I'm not 100% clear on the -u flag but i think this is just a shorthand for setting a link to the remote branch. :-)

Kevin Korte
Kevin Korte
28,148 Points

You're right Jonathan, -u is just shorthand for basically the same thing

If you already have a local branch and want to set it to a remote branch you just pulled down, or want to change the upstream branch youโ€™re tracking, you can use the -u or --set-upstream-to option to git branch to explicitly set it at any time. https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches#Tracking-Branches