Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools

Y B
Y B
14,136 Points

Challenge: git push branch to remote repository

In the git tutorial I can get past the challenge where it asks to push to a remote repository

Q: Now that you've cloned that repository, let's say you've done some work on a branch named "awesome_stuff." What command would you run to push that branch up to your remote?

My answer: git push git://mygithosting.com/git_basics/cool_stuff.git. awesome_stuff

However this fails, but I'm not sure why?

3 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Y B;

Once you have cloned a repository Git recreates a remote named origin for us. So, we would need to use:

git push origin awesome_stuff

Which does just what it sounds like, it pushes our awesome_stuff branch back to the origin, which Git knows about.

Post back with further questions.

Ken

Y B
Y B
14,136 Points

Thanks I thought that was a specific example in the tutorial not the general case. Does git always set it up as origin after cloning a repository?

Ken Alger
Ken Alger
Treehouse Teacher

If you take a look at the documentation for clone you will see that:

This default configuration is achieved by creating references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.

Happy coding,

Ken

Y B
Y B
14,136 Points

Thanks