-1

I have done the changes in my local repository and when i was pushing the changes to github it showed me this, what do I do?

Updates were rejected because the remote contains work that you do hint i got from ubuntu: not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes(e.g., 'git pull ...') before pushing again. See the 'Note about fast-forwards' in 'git push --help' for details.

PS: I'm new on git.

  • The resolution to this problem is in the very error message which you pasted above. Just do a `git pull` to bring in those latest changes before you push. – Tim Biegeleisen Jul 10 '18 at 06:20
  • @TimBiegeleisen But what if i don't want to pull the contents from the other contributors? what if that is useless for my current work? – Siddhant Shrivastava Jul 10 '18 at 06:40
  • Git workflows don't really work this way. If you don't want the other material, then it might indicate you should be working on separate/different branch. – Tim Biegeleisen Jul 10 '18 at 06:41
  • `git pull` pulls the changes of the same branch? or from all branches altogether? – Siddhant Shrivastava Jul 10 '18 at 06:49
  • It depends on what version you use. `git pull origin master` pulls from the remote `master` branch into whatever local branch you are currently using. Typically, that local branch would also be `master`. – Tim Biegeleisen Jul 10 '18 at 06:50
  • Possible duplicate of [git: updates were rejected because the remote contains work that you do not have locally](https://stackoverflow.com/questions/24357108/git-updates-were-rejected-because-the-remote-contains-work-that-you-do-not-have) – phd Jul 10 '18 at 18:13

1 Answers1

1

Prior to pushing ur changes; pull from the repository. Follow the set of commands sequentially.

git stash; // will dump ur changes.

git pull origin branch_name; // If pulling from same branch git pull is enough.

git stash pop; // the dumped changes in the first step will be retrieved.

git push;