Issue pushing to a GitHub repository created with "Initialize repo with a README" option
17:00 25 Apr 2014

I tried to create a GitHub repository using the instructions in the GitHub documentation, except instead of making a README locally, I initialized my GitHub repository with the README option. After trying to push, though, I get this error I don't fully understand:

kirby:cs61as_SCIP_schython \**user**$ git push origin master
https://github.com/chris-marie/cs61as_SICP_schython.git 
! [rejected] 
master -> master (fetch first) error: failed to push some refs to
'https://github.com/chris-marie/cs61as_SICP_schython.git' 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 merge the remote
changes (e.g., hint: 'git pull') before pushing again. hint: See the
'Note about fast-forwards' in 'git push --help' for details.

I couldn't pull the repository either, so I tried manually downloading, adding, and committing the README file I had created virtually and tried to push again, and got a new error:

kirby:cs61as_SCIP_schython \**user**$ git push origin master
https://github.com/chris-marie/cs61as_SICP_schython.git 
! [rejected] 
master -> master (non-fast-forward) error: failed to push some refs to
'https://github.com/chris-marie/cs61as_SICP_schython.git' hint:
Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git
pull') hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This leaves me with four questions:

  1. Why does it not work to initialize a remote repository on GitHub with a README, and then try to connect the GitHub repository with a previously existing existing local repository?

  2. Why could I not pull when I tried to fix this error?

  3. Why could I still not push and initialize the connection to my GitHub remote after I added the README from GitHub to my local repository manually?

  4. How do I create a GitHub repository with an initialized README and connect it to a local repo without causing these errors?

git github