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

git push rejected, non_fast_forward updates were rejected

I'm at an impasse with this lesson. Not sure how I can continue without completely wiping everything and starting over. Please advise.

Below is from my terminal like (BTW! How can I copy+paste from workspaces? I opted to screenshot my terminal and manually type this out, not convenient.)

**

treehouse ~/our_clone_project $ git_push To /home/treehouse/my_really_cool_project/ | [rejected] new_feature -> new_feature (non-fast-forward) error: failed to push some refs to '/home/treehouse/my_really_cool_project/' To prevent you from losing history, non-fast-forward updates were rejjected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.

**

I did read that note, however it's currently above my level. Also, it recommend to git pull, which doesn't fix my problem.

1 Answer

Zuhayr Elahi
Zuhayr Elahi
2,582 Points

Hmm, it looks like your local repo may not be at the same level as the remote repo. Meaning there could have been changes which were committed and now your local repo is behind. I believe this is why you are getting the issue. So its asking you to update your local repository so that it matches the remote one. This is what I think, but if possible could you show what the error message is when you do a git pul?

When I enter git push origin new_feature I get the same error that John is getting. I searched "git match local repository to remote repository", and based on the results I ran the following commands:

git fetch origin
git reset --hard origin/master

Then I tried entering git push origin new_feature again but I got the same error. I'm very new to this, so maybe those were not the commands that I should have used to update my local repository. Any help would be greatly appreciated, as I'm also at an impasse with this lesson.

Thanks!