Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Why is my GitHub push getting rejected?

+2 votes
asked Sep 7 in CSC 285 (F17) by Forrest Stonedahl (3,153 points)

1 Answer

+3 votes

For Lab 1, several people edited the README.MD file directly on GitHub, which caused a "commit" to happen in that remote repository, *before* trying to push their committed changes from their local repository (i.e. the actual Java code for the game, etc).

In this case, when you try to push, it will say "rejected" because the remote repository has work that might conflict with yours, and it won't do any merging on the remote end.

To solve this:

a) do a "git pull" to bring down the remote changes to your local repo

b) If you did this from the command line, it may pop up an editor screen with a "Merge ..." message.  To exit this screen, you need to type ":q"  (The colon is important).

c) If you also edited README.MD locally, as well as remotely on GitHub, then you could have a conflict, which you'll have to resolve before you can finish the merge commit and push.  That's beyond the scope of what I have time to explain in this answer right now.  We'll cover this in the next GitHub lab...

d) Otherwise, the merge should have completed successfully, and you should now be able to push your changes back up to GitHub.

answered Sep 7 by Forrest Stonedahl (3,153 points)
This fixed all my problems. Thank you very much!!
...