To https://github.com/firstrepo/first-project.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/firstrepo/first-project.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.
            Asked
            
        
        
            Active
            
        
            Viewed 496 times
        
    -2
            
            
         
    
    
        CryptoFool
        
- 21,719
- 5
- 26
- 44
 
    
    
        firatinlkc
        
- 30
- 6
- 
                    You can run `git pull` to get updates from the online repository and then `git push` to try to push again. – Andrew Mascillaro Feb 27 '21 at 16:01
- 
                    1Does this answer your question? [git error: failed to push some refs to remote](https://stackoverflow.com/questions/24114676/git-error-failed-to-push-some-refs-to-remote) – Andrew Mascillaro Feb 27 '21 at 16:02
- 
                    https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+remote+contains+work+that+you+do – phd Feb 27 '21 at 16:24
2 Answers
1
            Pull the changes first with git pull and after git push. Seems that the online repo has more folders/files than your code in local on your computer. Are other people working on the same project together with you?
 
    
    
        EmanueleDB
        
- 26
- 1
- 3
0
            
            
        This error occurs when you make any changes to your github repo manually by going to github site, which causes a conflict b/w your local repo and the github repo. As shown in the error, use git pull to match them again and then use the same commands again
 
    
    
        Irfan wani
        
- 4,084
- 2
- 19
- 34