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

Emily Kapor-Mater
Emily Kapor-Mater
1,916 Points

Git push and pull tutorial video fails on Mac OS X Yosemite

Everything is going swimmingly until I get to "git push". I'm following along on my Mac, OS X Yosemite, with Git 2.3.2 (what's installed by default). I do "git push" and I get the error:

warning: push.default is unset; its implicit value has changed in Git 2.0 from 'matching' to 'simple'. To squelch this message and maintain the traditional behavior, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to 'matching', git will push local branches to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple' behavior, which only pushes the current branch to the corresponding remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information. (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 'current' instead of 'simple' if you sometimes use older versions of Git)

fatal: The current branch new_feature has no upstream branch. To push the current branch and set the remote as upstream, use

git push --set-upstream origin new_feature

And I'm lost!

6 Answers

It's an update git made very recently. They're changing the default way you push to prevent users who may be inexperienced from force pushing branches that are older than a branch pushed recently. This will help prevent users from potentially losing their work or someone else's. It was introduced in Git 2.0.

Here is a pretty good explanation I found:

"The new simple behavior is a lot like the upstream setting: it only pushes the current branch that you're currently on, if it has a remote branch that it's tracking. It adds one extra criteria: the remote branch must have the same name as the local one."

git config --global push.default simple To get Git's default behavior but without the warning message, use:

git config --global push.default matching I'd really advise against using matching though. In general, most people really want the new simple behavior, or upstream.

Have you tried type the command it tells you to type?

git config --global push.default simple

Getting the same error with $ git push locally or to Github. Based on what Chris said, maybe we need to make (identify?) a repository upstream.

Still, I'm not exactly sure about "repository" and "upstream". Could anyone clarify those terms?

Also, this stackoverflow article addresses the same issue. Following their explanation, I successfully pushed code to the master branch using $ git push origin master

Emily Kapor-Mater
Emily Kapor-Mater
1,916 Points

It does something but I'm not certain how it works or why or whether it works the same way it does in the video. Is there a way to make the behavior on my computer mirror what is the behavior in the video?

Chris Shaw
Chris Shaw
26,676 Points

Hi Emily,

jordans answer pretty much nails the first question you had, your second question is related to having no upstream repository to push to. In English this means that you don't have anywhere to push your code to as you've not defined a GIT server with a repository.

The easiest way you can get working with GIT quickly and free is via BitBucket, simply sign up for an account when them and when you create a new repo they will walk you through the steps on getting setup locally as well.

Hope that helps answer your second question.

Mathew Kurian
Mathew Kurian
4,698 Points

Hey guys I had this same problem. I did a push command, "git push our_clone" as told in the video. And then I got this error message.

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream our_clone master

So I used the command, "git push --set-upstream our_clone master", and then it gets pushed. But I was wondering what this command does exactly? Do we have to set up a GIT server as Chris said?