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 Pushing and Pulling

Kartik Kapoor
Kartik Kapoor
3,016 Points

To run $ git push in a cloned repository is it necessary that we should be on branch master in the original repository?

If I try to run $ git push in a cloned repository it gives me an error message.But when I switch to branch master in the original repository and then run the push command from the cloned repository it works just fine.Why is this happening?

1 Answer

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

I think that's probably because you don't have that branch in the remote repo yet, that's why the git push without argument won't work.

Say if you're working on a new test local branch, you first need to git push -u origin test to create the branch in your remote repo and push your code up there; then you can push it to that branch with just git push.