1

I am newbie on git so my client need to upload code on bitbucket regularly. I have created a repo. and uploaded my first project by these steps in my porject directory

git init
git add .
git commit -m "my commit"
git remote set-url origin git@github.com:username/repo.git
git push origin master

And its uploaded successfully. But now when i work on my project i need to upload it. So i just run command again git push origin master its showing me error

git push to url  ! [rejected]        master -> master (fetch first)

I know if use --force it will work fine but my i cant use force because there is a team working on project so many people are uploading code regularly so force is causing many problem. I need some good or best practive solution or some type of guide you guys use to this regulary Thanks

UmaiZ
  • 93
  • 6
  • 18
  • 1
    Does this answer your question? [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 Jan 26 '20 at 17:50
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+remote+contains+work+that+you+do – phd Jan 26 '20 at 17:50

1 Answers1

0

The reason of your conflict - is a difference between local and remote branch. Compare git log of them and check last commits. I guess remote brach contains some extra commits, so you should pull them to local branch before pushing your local changes. Comment message '[rejected] master -> master (fetch first)' tells you about this situation.