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

General Discussion

Git Quiz: Remotes: Question 2

Question 2, confused me. It says, "Now that you have cloned that repository, let us say you have done some work on a branch named 'awesome_stuff'. What command would you run to push that branch up to your remote?'"

I got this wrong several times. My understanding is that the syntax to use is: git push remoteRepositoryName branchName

Where remoteRepositoryName is where you want to push your changes to ie your destination. branchName is the name of the branch you want to create at the destination ie "awesome_stuff".

I typed "git push remote awesome_stuff" , this is wrong The answer is "git push origin awesome_stuff".

My question is why? "Origin" is the repository on which the branch "awesome_stuff" was created, so there is no need to push changes there. Why would the remoteRepositoryName not be the destination ie "remote".

Thanks in advance.

1 Answer

Justin Ellingwood
Justin Ellingwood
12,545 Points

Hi Jerome,

Let me see if I can clear any of this up.

In git, a remote simply refers to another location where the project files reside. This could be the main project page on a site like GitHub, or your friend's copy of the repository who you share changes with. The files that your local repo and the remote repo share are not necessarily going to always be in-sync.

When you clone a repository initially to get it onto your computer, you copy the entire repository from a remote location to your local computer. During this processes, git will add a remote to your local copy of the repository called origin. This will point to the location of the repository that you cloned from. It is the same project, but the original copy that exists on a different computer.

So when you create a branch called "awesome_stuff", this branch only exists in your local repository. You need to push your changes to the remote repository, and that remote's name is origin. This will make your new branch available to anyone else who wishes to clone from the same location that you cloned from.

Justin, thanks for the explanation.

I see now, the local (cloned) repository, when referring to the repository it was cloned from. That repository should be referred to as the origin.

Thanks for taking the time to make that clear to me.