-4

I am new to github when I am trying to push files in the repository I am getting the following error:

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.

What is the way out and why is the error happening?

adjan
  • 13,371
  • 2
  • 31
  • 48
Prashant Kumar
  • 121
  • 1
  • 1
  • 7
  • possible duplicate of [Git push rejected "non-fast-forward"](http://stackoverflow.com/questions/20467179/git-push-rejected-non-fast-forward) – Andrew C May 04 '15 at 19:34

1 Answers1

1

When you're pushing to a repository, you should do a 'git pull' on that repository, to make sure that you have the most up to date version. Git is telling you that the repository was updated, but you do not have all of the updated information.

This stops people from pushing information into the repository that may not compile with the rest of the work in it, as you can't check for functionality without having all of the information. So try and do a 'git pull' from the repository, update, and then push the information you have to the repository, and it should go through.