-1

I am trying new to software development and git/github and trying to push a local repository on github and getting the following error..

Error:-

  • PS C:\Users\akcai\OneDrive\Desktop\PollingApplication> git push -u origin master
    To https://github.com/atharvamishra123/polling_application.git
    ! [rejected] master -> master (fetch first)
    error: failed to push some refs to 'https://github.com/atharvamishra123/polling_application.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 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.

command which i run are in the following manner:-

  • PS C:\Users\akcai\OneDrive\Desktop\PollingApplication> history
    Id CommandLine
    -- ----------- 1 cd OneDrive
    2 cd Desktop
    3 ls
    4 cd PollingApplication
    5 ls
    6 git init
    7 git add .
    8 git commit -m "initial_version_complete"
    9 git remote add origin https://github.com/atharvamishra123/polling_application.git
    10 git push -u origin master

please help i am unable to figure out what is the correct way to push local git repo on github.

Thanks in advance

Hope to here from you soon

Atharva
  • 87
  • 1
  • 9
  • 2
    Always search for existing questions first (see [ask]) - if you had put , e.g.,`Updates were rejected because the remote contains work that you do` into the search box, you'd get dozens of these. – torek Oct 12 '21 at 04:11
  • 1
    Side note: in Git, commit messages are human readable, so please feel free to use spaces and descriptive messages (instead of messages like "initial_version_complete"). [Here's one popular example.](https://chris.beams.io/posts/git-commit/) – TTT Oct 12 '21 at 04:14

1 Answers1

1

First you need to do "git pull". Then "git push origin master"

This happens because the most recent changes to the reference must be updated before pushing

Raul Larriega
  • 311
  • 2
  • 6