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

Josh Calkins
Josh Calkins
3,623 Points

Error message when trying to push to remote repository on the same machine

Hey guys! I keep getting the error message listed below whenever I try to push using this command: $ git push origin new_feature. I couldn't find anything on StackOverflow or the message boards and I'm stumped. I'm running Git version 2.3.8, thanks in advance for any help!

To /Users/Josh/cool_project ! [rejected] new_feature -> new_feature (fetch first) error: failed to push some refs to '/Users/Josh/cool_project' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

1 Answer

There are differences between your local and hosted repo so you need to git pull to match the changes then push again.