-2

Whenever I trying to push to remote repo through git error occurs. I have tried with my both github and gitlab account. But both times failled. Point to be noted that I'm having a github account named RusselVyper and for this project I created a new GitHub account named joyprakashdas. So is it colliding or what? I'm novice so please help me to grasp.
GitHub problems image

GitLab Problem showoff

Russel
  • 17
  • 5
  • The error you get on the second picture is because the remote branch have modifications that you don't have in local. To fix you'll need to first get the modifications and then push. If you want a good way to learn git, there is a site tha'ts pretty good doing that : https://learngitbranching.js.org/?locale=en_EN – polypode Oct 29 '21 at 07:38
  • Does this answer your question? [Github "Updates were rejected because the remote contains work that you do not have locally."](https://stackoverflow.com/questions/18328800/github-updates-were-rejected-because-the-remote-contains-work-that-you-do-not-h) – sytech Oct 29 '21 at 07:39
  • As a noob I forgot that to push something to someone else's repo I need permission or the owner of the repo should needs to add me as a collaborator. On the first and second both Image above, I was trying to push my code to someone else's GitHub Repo without having the power of collaborator. My problem is solved by adding me as a collaborator to the project. Thanks to everyone dude – Russel Oct 29 '21 at 12:30

1 Answers1

0

You have to pull commit which are on the remote but not in you local clone.

In such situation, I suggest to issue git pull --rebase in order to get remote commits and apply you local commit on top of the them, as if you already had them locally.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
  • As a noob I forgot that to push something to someone else's repo I need permission of the owner or the owner should needs to add me as a collaborator. On the first and second both Image above, I was trying to push my code to someone else's GitHub Repo without having the power of collaborator. (fun part is, I created the account for someone else and was trying to push code to that :-) without adding me as a collaborator ). I Solved the issue . Thanks Antonio – Russel Oct 29 '21 at 12:38